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.
A published result changed on 2026-10-14: Slope, aspect, and hillshade (version 1.1.0) now scales hillshade the way gdaldem does: 1 plus 254 times the cosine of the angle to the sun, and 1… Changelog
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.1.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
- None
- Cites
- Horn, B. K. P., Proceedings of the IEEE, Hill shading and the reflectance map; GDAL/OGR contributors, Open Source Geospatial Foundation, gdal raster hillshade
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 v022, 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
- 175
- 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.1.0, core 0.1.0. See this tool in the verification report.
Changes
- 2026-10-14, result change: Slope, aspect, and hillshade (version 1.1.0) now scales hillshade the way gdaldem does: 1 plus 254 times the cosine of the angle to the sun, and 1 where the ground faces away. The old result used 255 times the cosine and ran up to one gray level low. Hillshade now matches gdaldem exactly on all 1,452 test windows; slope and aspect are unchanged. Changelog
Checked against: 21 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.
Constants this tool assumes
Values you do not enter, and where each comes from.
- WGS 84 semi-major axis, for cell sizes given in degrees
6378137 m— Department of Defense World Geodetic System 1984- WGS 84 inverse flattening, for cell sizes given in degrees
298.257223563— Department of Defense World Geodetic System 1984- Default hillshade vertical exaggeration
1— GDAL raster hillshade documentation- Default hillshade light azimuth
315 deg— GDAL raster hillshade documentation- Default hillshade light altitude
45 deg— GDAL raster hillshade documentation
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.
- gdal raster hillshade, GDAL/OGR contributors, Open Source Geospatial Foundation, GDAL 3.13.3 documentation. Options: z-factor 1, azimuth 315°, altitude 45°, and Horn gradient defaults.