REL

Shaded relief from elevation data


EnvironmentsPYTHON :: EASI :: MODELER
Batch ModeYes
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Algorithm :: Related

Back to top

Description


Employs a user-specified light source to convert an elevation channel to a shaded relief image. Relief values are scaled from 0 to 255. The REL function is similar in function, but ANG differs in that it produces the ANGLES of incidence between a surface and a POINT source of light.
Back to top

Parameters


Name Type Length Value range
Input: Input elevation data channel * Raster port 1 - 1  
Output: Output shaded relief channel * Raster port 1 - 1  
Elevation Step Size Float 0 - 1 0.0 - 10.0
Default: 1
Pixel X Size Float 0 - 2
Default: 
Pixel Y Size Float 0 - 2
Default: 
Azimuth Angle of Light Source Float 2 - 2 0.0 - 360.0
Default: 225.0
Elevation Angle of Light Source Float 2 - 2 0.0 - 180.0
Default: 30.0

* Required parameter
Back to top

Parameter descriptions

Input: Input elevation data channel

Specifies the channel containing the elevation data.

Output: Output shaded relief channel

Specifies the output channel to receive the shaded relief image.

If the output file is the same as the input file, the output channel must be different from the input channel.

Elevation Step Size

Specifies, in meters, the elevation change corresponding to a change of one gray level. If this parameter is not specified, it defaults to 1 meter. Correct calculation of the shaded relief depends on the proper specification of this value.

Pixel X Size

Specifies, in meters, the X dimension of one pixel on the ground.

Correct calculation of the shaded relief depends on the proper specification of this value.

Pixel Y Size

Specifies, in meters, the Y dimension of one pixel on the ground.

Correct calculation of the shaded relief depends on the proper specification of this value.

Azimuth Angle of Light Source

Specifies, in degrees, the azimuth angle of the diffuse light source.

This value can be any non-negative number; values greater than 359 degrees are treated as MOD(360). The default value is 225.0.

Elevation Angle of Light Source

Specifies, in degrees, the elevation angle of the diffuse light source.

This value must be between 0 and 180 degrees. The default value is 30.0.

Back to top

Details

REL uses the elevation channel stored in the input file to create a shaded relief image in the output file, based upon a user-specified light source position.

Assuming that a line is drawn connecting the point source to the top-left pixel of the image, the azimuth angle is the azimuth of this line in degrees clockwise from north (top of the image); the elevation angle is the elevation of the line in degrees from the horizontal.

Correct representation of shaded relief depends on the proper specification of the elevation increment and the ground pixel size. If unspecified, the elevation step size is set to 1.

The shaded gray level at a point is calculated as the cosine of the angle between the normal vector to the surface (that is, slope and aspect) and the direction of illumination, scaled to the range of 0 to 255. If a different output range is desired, the MODEL function can be used to rescale the output channel.

All surfaces not illuminated by the light source (that is, with an angle greater than 90 degrees or a negative cosine) are set to 0.

The REL and ANG functions are similar in function, but differ on the following points: ANG produces the ANGLES of incidence between a surface and a point source of light; REL produces the amount of LIGHT reflected from a surface and a point light source.

Back to top

Algorithm

We convert the azimuth and elevation angle values for the diffuse light source in LSRC to a unit vector (lx,ly,lz):

    lx = -sin(LSRC(1)) * cos(LSRC(2))
    ly =  cos(LSRC(1)) * cos(LSRC(2))
    lz =  sin(LSRC(2))

For each pixel p = (px,py,pz) we define px,py as the pixel/row location and pz as the elevation. The immediate neighbors of p are a,b,c,d where a=(px,py-1,az), b=(px-1,py,bz), etc.

        . a .
        b p c
        . d .
We calculate the shaded relief as follows:
  1. Define two vectors, V1 and V2, across the pixel in question:

       V1 = (dx,0,dzx) = (2*PXSZ(1),0,(bz-cz)*ELSZ)   (left to right)
       V2 = (0,dy,dzy) = (0,2*PXSZ(2),(az-dz)*ELSZ)   (top to bottom)
    

    where dzx and dzy are the elevation changes between pixels, and dx and dy are the projected distances between pixels. PXSZ and ELSZ are parameters specified by the user giving pixel ground size and elevation sizes. dx and dy will be twice the actual pixel ground size because the elevation differences (or gradients) are taken over 2-pixel distances.

  2. Find the normal vector to the plane formed by the two vectors V1 and V2, by taking the cross product:

         N = V1 X V2 = (-dy*dzx, -dx*dzy, dx*dy) = (nx, ny, nz)
    

The cosine of the angle between the normal vector and the light source vector is the dot product of the vectors divided by the sum of their magnitudes:

   cos(ang) = (nx*lx + ny*ly + nz*lz) /                  
          (sqrt(nx**2+ny**2+nz**2)*sqrt(lx**2+ly**2+lz**2))

Then:

   if (cos(ang) < 0) then
      shaded relief value = 0
   else
      shaded relief value = cos(ang) * 255
   endif

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.