How Hillshade works

The Hillshade tool obtains the hypothetical illumination of a surface by determining illumination values for each cell in a raster. It does this by setting a position for a hypothetical light source and calculating the illumination values of each cell in relation to neighboring cells. It can greatly enhance the visualization of a surface for analysis or graphical display, especially when using transparency.

By default, shadow and light are shades of gray associated with integers from 0 to 255 (increasing from black to white).

The hillshade parameters

The primary factor when creating a hillshade map for any particular location is the location of the sun in the sky.


The azimuth is the angular direction of the sun, measured from north in clockwise degrees from 0 to 360. An azimuth of 90º is east. The default azimuth is 315º (NW).

Default sun azimuth (direction) for hillshade is 315º
Default sun azimuth (direction) for hillshade is 315º


The altitude is the slope or angle of the illumination source above the horizon. The units are in degrees, from 0 (on the horizon) to 90 (overhead). The default is 45 degrees.

Default sun altitude for hillshade is 45
Default sun altitude for hillshade is 45º

The hillshade example below has an azimuth of 315º and an altitude of 45º.

Hillshade output example
Hillshade output example

Using hillshade for display

By placing an elevation raster on top of a hillshade raster and adjusting the transparency of the elevation raster, you can easily create a visually appealing relief map of a landscape.

Using transparency to combine elevation raster with hillshade
Create a shaded relief raster by combining elevation and hillshade rasters with transparency

You can add other layers, such as land-use types, vegetation, roads, or streams, to further increase the informational content in the display.

Using hillshade in analysis

By modeling shade (the default option), you can calculate the local illumination and whether the cell falls in a shadow or not.

By modeling shadow, you can identify each cell that will be in the shadow of another cell at a particular time of day. Cells that are in the shadow of another cell are coded 0; all other cells are coded with integers from 1 to 255. You can reclassify all values greater than 1 to 1, producing a binary output raster. In the example below, the black areas are in shadow. The azimuth is the same in each image, but the sun angle (altitude) has been modified.

Shadows with low sun angle
Shadows with low sun angle
Shadows with high sun angle
Shadows with high sun angle

How hillshade is calculated

To calculate the shade value, first the altitude and azimuth of the illumination source are needed. These values will be processed along with calculations for slope and aspect to determine the final hillshade value for each cell in the output raster.

The hillshade algorithm

The algorithm for calculating the hillshade value is the following:

(1)  Hillshade = 255.0 * ((cos(Zenith_rad) * cos(Slope_rad)) +
                 (sin(Zenith_rad) * sin(Slope_rad) * cos(Azimuth_rad - Aspect_rad)))

Note that if the calculation of the hillshade value is < 0, the output cell value will be = 0.

Computing the illumination angle

The altitude of the illumination source is specified in degrees above horizontal. However, the formula for calculating the hillshade value requires that the angle be represented in radians and be the deflection from the vertical. The direction straight up from the surface (directly overhead) is labeled the Zenith. The zenith angle is measured from the zenith point to the direction of the illumination source and is the 90° complement to the altitude. To calculate the illumination angle, the first step is to convert the altitude angle to the zenith angle. The second step is to convert the angle to radians.

Changing altitude to zenith angle:

(2)  Zenith_deg = 90 - Altitude

Convert to radians:

(3)  Zenith_rad = Zenith * pi / 180.0

Computing the illumination direction

The direction of the illumination source, azimuth, is specified in degrees. The hillshade formula requires this angle to be in units of radians. First, the azimuth angle is changed from its geographic unit (compass direction) to a mathematic unit (right angle). Next, the azimuth angle is converted to radians.

Change azimuth angle measure:

(4)  Azimuth_math = 360.0 - Azimuth + 90

Note that if Azimuth_math >= 360.0, then:

(5)  Azimuth_math = Azimuth_math - 360.0

Convert to radians:

(6)  Azimuth_rad = Azimuth_math * pi / 180.0

Computing Slope and Aspect

A moving 3 x 3 window visits each cell in the input raster, and for each cell in the center of the window, an aspect and slope value is calculated using an algorithm that incorporates the values of the cell's eight neighbors. The cells are identified as letters a to i, with e representing the cell for which the aspect is being calculated.

The rate of change in the x direction for cell e is calculated with the following algorithm:

(7)  [dz/dx] = ((c + 2f + i) - (a + 2d + g)) / (8 * cellsize)

The rate of change in the y direction for cell 'e' is calculated with the following algorithm:

(8)  [dz/dy] = ((g + 2h + i) - (a + 2b + c)) / (8 * cellsize)

The steepest downhill descent from each cell in the surface is the slope. The algorithm for calculating the slope in radians, incorporating the z-factor, is:

(9)  Slope_rad = ATAN (z_factor * √ ([dz/dx]2 + [dz/dy]2)) 

The direction the steepest downslope direction is facing is the aspect. Aspect in radians is defined in the range of 0 to 2pi, with 0 toward east. The aspect is determined under the rules in the following algorithm:

  If [dz/dx] is non-zero:
    Aspect_rad = atan2 ([dz/dy], -[dz/dx])
      if Aspect_rad < 0 then
        Aspect_rad = 2 * pi + Aspect_rad

  If [dz/dx] is zero:
    if [dz/dy] > 0 then
      Aspect_rad = pi / 2
    else if [dz/dy] < 0 then
      Aspect_rad = 2 * pi - pi / 2
      Aspect_rad = Aspect_rad

A hillshade calculation example

As an example, the hillshade value of the center cell of the moving window will be calculated.

Input elevation raster
Input elevation raster

The cell size is 5 units. The default Altitude of 45 degrees and Azimuth of 315 degrees will be used.

Since the output raster is of integer type, the shade value for center cell e = 154.


Burrough, P. A. and McDonell, R. A., 1998. Principles of Geographical Information Systems (Oxford University Press, New York), 190 pp.

Related Topics