Skip to content

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 ​

ParameterTypeDescription
gridGridInterfaceElevation grid, heights in m.
sunAzimuthRadiansSun's azimuth in radians, clockwise from north (finite).
sunElevationRadiansSun's elevation above the horizon in radians (in [−π/2, π/2]).

Returns ​

GridInterface

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 sunElevation is outside [−π/2, π/2].

Example ​

ts
// The cartographers' convention: light from the north-west, 45° up
const shaded = hillshadeGrid(grid, toRad(315), toRad(45));

See ​

hillshadeAt