Slope, aspect, and hillshade
Slope, aspect, and hillshade for the center of a 3 x 3 elevation window by Horn's method, with the cell size corrected for latitude on a degree-based grid.
Experimental: not yet fully verified. How results are checked
The slope is 1.92° (3.35%), facing south-east.
- Slope, percent
- Aspect
- Facing
- Hillshade
- Cell size east
- Cell size north
Provenance
- Computed by
- raster.terrain.slope-aspect 1.0.0, core 0.1.0
- Model
- Horn's (1981) eight-neighbor gradients: dz/dx = ((c + 2f + i) - (a + 2d + g)) / 8dx, dz/dy from the rows; slope = atan(z x hypot), aspect clockwise from north, hillshade from the sun's zenith and azimuth as gdaldem computes it
- Accuracy
- Exact evaluation of Horn's formulas. On a degree-based grid the cell sizes come from the WGS 84 meridian and prime-vertical radii at the latitude given.
- Notes
- 1 shown with the answer
- Cites
- Horn, B. K. P., Proceedings of the IEEE, Hill shading and the reflectance map
Something look off?
How we got thisFormula, worked example, sources, and proof
Model: Horn's (1981) eight-neighbor gradients: dz/dx = ((c + 2f + i) - (a + 2d + g)) / 8dx, dz/dy from the rows; slope = atan(z x hypot), aspect clockwise from north, hillshade from the sun's zenith and azimuth as gdaldem computes it
Accuracy: Exact evaluation of Horn's formulas. On a degree-based grid the cell sizes come from the WGS 84 meridian and prime-vertical radii at the latitude given.
When to use this: Use this to see what a DEM says about one cell, and to check a raster pipeline against a hand-worked case: the nine elevations in, the slope, the aspect, and the hillshade out, with the cell sizes actually used. It is also the way to see how much a degree-based grid's latitude correction matters, which is where slope from an unprojected DEM usually goes wrong.
Limitations: It works on the nine elevations you give, not on a raster: a whole-DEM version belongs with the GeoTIFF tools. Horn's method smooths, so a slope from a coarse DEM is gentler than the ground; and the answer is only as good as the elevation model, which for a surface model includes buildings and canopy rather than the ground under them.
Worked example: A 30 m window falling to the south-east. Source: Horn's formulas worked independently in Python (tools/vectors/gen_raster.py). It is golden test vector v001, and every build checks the tool still gives its answer within its tolerance.
You enter
- Cell size
- 30 m
- Elevation window
- 101.2, 100.6, 100.2 100.4, 99.8, 99.2 99.6, 99.0, 98.4
You get
- Slope
- 1.92°
- Slope, percent
- 3.35
- Aspect
- 145.125°
- Facing
- south-east
- Hillshade
- 174
- Cell size east
- 30 m
- Cell size north
- 30 m
Review: Not yet independently reviewed by a GIS professional.
Last verified: 2026-09-22, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.
Status: version 1.0.0, core 0.1.0. See this tool in the verification report.
Checked against: 7 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.
Sources
- Hill shading and the reflectance map, Horn, B. K. P., Proceedings of the IEEE, Volume 69, issue 1, pages 14-47. The eight-neighbor gradient estimate used for slope, aspect, and hill shading.
Experimental means this tool has not yet met the stable bar: at least 20 golden vectors, differential tests, and an independent worked example.