Skip to content

Documentation / @interstellar-tools/maps / gridValueAt

Function: gridValueAt() ​

ts
function gridValueAt(grid: GridInterface, row: number, column: number): number;

Defined in: terrain/grid.ts:117

Read the value of one cell of a grid.

Parameters ​

ParameterTypeDescription
gridGridInterfaceThe grid.
rownumberRow index, 0 at the north edge (an integer in [0, rows)).
columnnumberColumn index, 0 at the west edge (an integer in [0, columns)).

Returns ​

number

The value, or NaN for a missing cell (noData or NaN).

Throws ​

If row or column is not an integer inside the grid.

Example ​

ts
const grid = createGrid({
  rows: 2,
  columns: 2,
  values: [10, 11, -9999, 13],
  cellSize: { x: 30, y: 30 },
  noData: -9999
});

gridValueAt(grid, 0, 1); // 11
gridValueAt(grid, 1, 0); // NaN

See ​

createGrid