Hillshade value for one DEM cell
The hillshade brightness, 1 to 255, at the center of a 3 x 3 elevation window for a sun at a given azimuth and altitude, as gdaldem computes it.
The hillshade value is 197 on a scale of 1 to 255.
Provenance
- Computed by
- raster.terrain.hillshade 1.0.0, core 0.1.0
- Model
- gdaldem's hillshade: 1 + 254 (cos Z cos S + sin Z sin S cos(A_sun - A)), rounded, and 1 where that cosine is zero or negative, from Horn's slope S and aspect A and the sun's zenith Z
- Accuracy
- Exact evaluation of gdaldem's formula; it matches gdaldem 3.13.3 on all 1,452 windows of the GDAL agreement test
- 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: gdaldem's hillshade: 1 + 254 (cos Z cos S + sin Z sin S cos(A_sun - A)), rounded, and 1 where that cosine is zero or negative, from Horn's slope S and aspect A and the sun's zenith Z
Accuracy: Exact evaluation of gdaldem's formula; it matches gdaldem 3.13.3 on all 1,452 windows of the GDAL agreement test
When to use this: Use this to check one pixel of a shaded-relief map, or to see how the sun's direction changes the shading of a slope: a lower sun or one from another side brings out different ridges. Enter the nine elevations, the cell size, and if you like the sun's azimuth and altitude; the defaults are the cartographic 315° and 45°.
Limitations: It works on the nine elevations you give, not on a raster. The value is a picture brightness, not a measure of real sunlight: it ignores shadows cast by other terrain, the atmosphere, and the time of day.
Worked example: A 5 m window lit from the west at 30°. Source: gdaldem 3.13.3 hillshade, matched by Horn's formulas in Python (tools/vectors/gen_terrain_views.py).
You enter
- Cell size
- 5 m
- Elevation window
- 10, 12, 11 9, 13, 14 8.5, 11.5, 12.5
- Sun altitude
- 30 deg
- Sun azimuth
- 270 deg
You get
- Hillshade
- 197
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.
Changes
- 2026-10-14, changed: Slope, aspect, hillshade, the terrain ruggedness index, and the topographic position index, each as its own tool, are now stable. Each matches gdaldem 3.13.3 on 24 windows (hillshade exactly; the rest within gdaldem's 32-bit rounding) and its parent tool on 208 fixture windows, with invariant tests for turning, raising, and inverting the ground. Results are unchanged. Changelog
Checked against: 25 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.
Terms
- DEM: digital elevation model
- A grid of elevations. A surface model includes buildings and canopy; a terrain model is the ground beneath them. Source: Copernicus DEM GLO-30