Skip to content

Documentation / @interstellar-tools/maps / slopeGrid

Function: slopeGrid() ​

ts
function slopeGrid(grid: GridInterface): GridInterface;

Defined in: terrain/slope.ts:81

Compute the slope of every cell of an elevation grid, as a new grid in radians.

See slopeAt. Cells on the edge and next to a missing cell are NaN.

Parameters ​

ParameterTypeDescription
gridGridInterfaceElevation grid, heights in m.

Returns ​

GridInterface

A grid of the same shape, slopes in radians.

Throws ​

  • If a size or cell size is not finite.
  • If the grid's parts don't fit together.

Example ​

ts
const slopes = slopeGrid(grid);
gridValueAt(slopes, 1, 1); // ≈ 0.0997 rad

See ​

slopeAt