Documentation / @interstellar-tools/maps / hillshadeGrid
Function: hillshadeGrid()
ts
function hillshadeGrid(
grid: GridInterface,
sunAzimuth: Radians,
sunElevation: Radians
): GridInterface;Defined in: terrain/hillshade.ts:140
Compute the hillshade of every cell of an elevation grid, as a new grid of brightness in [0, 1].
See hillshadeAt; the slope and aspect come from slopeAt and aspectAt. Cells on the edge and next to a missing cell are NaN.
Parameters
| Parameter | Type | Description |
|---|---|---|
grid | GridInterface | Elevation grid, heights in m. |
sunAzimuth | Radians | Sun's azimuth in radians, clockwise from north (finite). |
sunElevation | Radians | Sun's elevation above the horizon in radians (in [−π/2, π/2]). |
Returns
A grid of the same shape, hillshade in [0, 1].
Throws
- If a size, cell size or Sun angle is not finite.
- If the grid's parts don't fit together, or
sunElevationis outside [−π/2, π/2].
Example
ts
// The cartographers' convention: light from the north-west, 45° up
const shaded = hillshadeGrid(grid, toRad(315), toRad(45));