I have a detailed 5m DEM for my study area. I want to find regions or zones where the slope or aspect (or preferably both) varies little. In other words, a nice evenly sloped hillside with a consistent aspect should show up high value, whereas complex, rugged terrain should show up as low. I want to identify these areas of smooth terrain, and preferably rank them by some kind of area. I guess that means I have to specify some kind of threshold or tolerance of values which I consider to be similar - I don't expect the slope or aspect to be exactly the same at any point, particularly not with floating point values.

What kind of filter do I need to pass over my data to identify these rough areas? I have spatial analyst and 3D analyst.

  • 1
    Reclassify each and combine. You'll end up with limited number of combinations. Reclassify again
    – FelixIP
    Commented Apr 15, 2016 at 23:01
  • 1
    Much better solution to compute direct solar radiation. It will combine them both
    – FelixIP
    Commented Apr 15, 2016 at 23:33
  • Reclassify tool and then weighted overlay
    – ziggy
    Commented Nov 3, 2016 at 15:15

1 Answer 1


Slope and aspect together tell you about the normal direction to the surface. This is an arrow of unit length pointing straight out from the surface. At a horizontal point it is straight up; along a sheer cliff wall it is almost straight out.

The variation in this direction can be assessed using the spherical standard deviation of the normal direction within a local neighborhood. This is found by expressing the normal directions on the DEM's cells in terms of their displacements in a Cartesian (x,y,z) coordinate system. Averaging the x-coordinates, y-coordinates, and z-coordinates separately gives a vector (xb, yb, zb) pointing in the direction of the average normal. This vector will be shorter when there is more variation of the normals and it will be longest--equal to unity--when there is no variation. Its squared length is (by the Pythagorean theorem) given by

R^2 = xb^2 + yb^2 + zb^2

The value 1 - R^2, which will lie between 0 and 1 (up to floating point error), is the spherical variance. Its square root can be considered a "spherical standard deviation" (SD). It is a good solution to this problem. Pick locations where the spherical SD is close to zero.

To find the coordinates (x, y, z), use map algebra to compute the cosines and sines of the slope and aspect. Apply the formulas for converting between spherical and cartesian coordinates:

x = cos(aspect) * sin(slope)
y = sin(aspect) * sin(slope)
z = cos(slope)

After finding these three grids, compute the neighborhood means (focal means) of each one to obtain the grids (xb, yb, zb). Use the same neighborhood for each, such as a 3x3 or 5x5 neighborhood, extending approximately to a typical distance of the regions you wish to study. A final set of map algebra steps delivers a grid of R values.

As an example, here is a DEM of a mountainous region, shown hillshaded:


The legend at the left shows the sequence of calculations from bottom to top. Here is the resulting SD map, based on a 5 x 5 circular neighborhood (a radius of 150 meters):


The darkest blue areas are the flattest. They clearly occur in the piedmont region to the lower right and along some river valleys, especially in the middle left. Some of these flat regions are pretty steep: look at the incised stream valley immediately left of the prominent central peak (most of whose areas have high variance).

  • I tried your method with OpenSource-Software and 5x5m DEM. 1. Calculating x,y,z: gdal_calc -A aspect.tif -B slope.tif --calc="cos(A) * sin(B)" --outfile x.tif, and so on. 2. Then I used gdal_fillnodata x.tif -md 5 -si 2 x_filter.tif, explained here: link for the neighborhood means, but I don't know if this is right. Is GRASS GIS the better solution? 3. Calculating SD: gdal_calc -A x_filter.tif -B y_filter.tif -C z_filter.tif --calc="sqrt((A*A)+(B*B)+(C*C))" --outfile sqrt_r.tif. I think my mistake is the used filter.
    – Stefan
    Commented Dec 14, 2016 at 14:37
  • @Stefan I recommend viewing each intermediate raster as you create it to confirm your calculations are doing what you intend. In particular, verify that cos and sin are compatible with the units of degree measure used to express slope and aspect (in many GISes they are not: you have to convert degrees to radians explicitly).
    – whuber
    Commented Dec 14, 2016 at 15:56
  • Thank you for the advice "[...] convert degrees to radians explicitly". The raster units are in meters. The x,y,z raster are looking good, now. I have a peak at 2 (histogram) in my final raster. Is the formula, in my last comment, the right one? Do I have to calculate SD=sqrt(1-R²)?
    – Stefan
    Commented Dec 15, 2016 at 6:27
  • @Stefan You don't actually have to compute SD: it is close to zero if and only if R^2 is close to 1. However, maps of SD are likely to be more revealing and detailed than maps of R^2.
    – whuber
    Commented Dec 15, 2016 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.