How HillShade works

Available with Spatial Analyst license.

Available with 3D Analyst license.

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).

Hillshade parameters

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

Azimuth

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

Sun azimuth at 315 degrees
The default sun azimuth (direction) for hillshade is 315 degrees.

Altitude

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.

Sun altitude at 45 degrees
The default sun altitude for hillshade is 45 degrees.

Hillshade example

The following hillshade example has an azimuth of 315 degrees and an altitude of 45 degrees:

Hillshade output example
Hillshade output example

Hillshade use for display

By placing an elevation raster on top of a hillshade raster, and adjusting the transparency of the elevation raster, you can create a visually appealing relief map of a landscape. To learn how to adjust the display and appearance, see Imagery appearance.

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.

Hillshade use 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
A low sun angle results in more areas of shadow.
Shadows with high sun angle
A high sun angle results in fewer shadows.

Hillshade calculation

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

Hillshade algorithm

The algorithm for calculating the hillshade value is as follows:

(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 less than 0, the output cell value will be equal to 0.

Compute 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 degrees complement to the altitude. To calculate the illumination angle, first convert the altitude angle to the zenith angle. Next, convert the angle to radians.

Change altitude to zenith angle:

(2)  Zenith_deg = 90.0 - Altitude

Convert to radians:

(3)  Zenith_rad = Zenith_deg * pi / 180.0

Compute 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, change the azimuth angle from its geographic unit (compass direction) to a mathematic unit (right angle). Next, convert the azimuth angle to radians.

Change azimuth angle measure:

(4)  Azimuth_math = 360.0 - Azimuth + 90.0

Note that if Azimuth_math >= 360.0, the following is true:

(5)  Azimuth_math = Azimuth_math - 360.0

Convert to radians:

(6)  Azimuth_rad = Azimuth_math * pi / 180.0

Compute slope and aspect

A moving 3-by-3 window moves to each cell in the input raster, and for each cell in the center of the window, an aspect and slope value are 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 as follows:

(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:

(10)
  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
    else
      Aspect_rad = Aspect_rad

Hillshade calculation example

In this example, the hillshade value of the center cell of the moving window is calculated.

Input elevation raster

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

  • Illumination angle

    The calculation for zenith angle from equation 2 is as follows:

    (2)  Zenith_deg = 90.0 - Altitude 
                  = 90.0 - 45.0
                  = 45.0

    And converted to radians from equation 3 is as follows:

    (3)  Zenith_rad = Zenith_deg * pi / 180.0
                  = 45.0 * 3.1415926536 / 180.0
                  = 0.7853981634

  • Illumination direction

    The calculation for converting the azimuth angle from geographic to mathematic angle with equation 4 is as follows:

    (4)  Azimuth_math = 360.0 - Azimuth + 90.0
                    = 360.0 - 315.0 + 90.0
                    = 135.0

    Converting azimuth angle to radians with equation 6 is as follows:

    (6)  Azimuth_rad = Azimuth_math * pi / 180.0
                   = 135.0 * 3.1415926536 / 180
                   = 2.3561944902

  • Slope and aspect

    The calculation for the rate of change in the x direction for center cell e is as follows:

    (7)  [dz/dx] = ((c + 2f + i) - (a + 2d + g)) / (8 * cellsize)
                 = ((2483 + 4966 + 2477) - (2450 + 4904 + 2447)) / (8 * 5)
                 = (9926 - 9801) / 40
                 = 3.125

    The calculation for the rate of change in the y direction for center cell e is as follows:

    (8)  [dz/dy] = ((g + 2h + i) - (a + 2b + c)) / (8 * cellsize)
                 = (2447 + 4910 + 2477) - (2450 + 4922 + 2483) / (8 * 5)
                 = (9834 - 9855) / 40
                 = -0.525

    The calculation for the slope angle is as follows:

    (9)  Slope_rad = ATAN ( z_factor * √ ([dz/dx]2 + [dz/dy]2))
                 = atan(1 * sqrt((3.125 * 3.125) + (-0.525 * -0.525)))
                 = atan(1 * sqrt(10.04125 + 0.275625))
                 = atan(1 * 3.1687931457)
                 = 1.2651101670

    The calculation for the Aspect_rad angle from rule 10 is as follows (since dz/dx is nonzero in this example):

      Aspect_rad = atan2 ([dz/dy], -[dz/dx])
               = atan2(-0.525, -3.125)
               = -2.9751469600

    Since this value is less than 0, this part of the rule applies:

      Aspect_rad = 2 * pi + Aspect_rad
               = 2 * 3.1415926536 + -2.9751469600
               = 3.3080383471

  • Hillshade

    The final calculation for the hillshade is as follows:

      Hillshade = 255.0 * ((cos(Zenith_rad) * cos(Slope_rad)) + 
                 (sin(Zenith_rad) * sin(Slope_rad) * cos(Azimuth_rad - Aspect_rad)))
              = 255.0 * ((cos(0.7857142857) * cos(1.26511)) +
                 (sin(0.7857142857) * sin(1.26511) * cos(2.3571428571 - 3.310567)))
              = 153.82

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

References

Burrough, P. A., and R. A. McDonell. 1998. Principles of Geographical Information Systems. New York: Oxford University Press.

Related topics