geoprimsField-grade geospatial math

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.

197

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?

Your values

Showing an example. Change anything.
More options 3
Run many at once from a CSV

Loading…

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

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

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