Documentation / @interstellar-tools/maps / terrainRoughnessIndexAt
Function: terrainRoughnessIndexAt()
ts
function terrainRoughnessIndexAt(
grid: GridInterface,
row: number,
column: number
): number;Defined in: terrain/terrain-roughness-index.ts:53
Compute the Terrain Roughness Index of an elevation grid at a cell: the root-mean-square height difference between the cell and its eight neighbours.
Where:
is the cell's height (m) are the heights of its eight neighbours (m)
Units
- Input: heights in m.
- Output: TRI in m, ≥ 0: 0 is level.
Notes
- How uneven the ground is around a cell: boulders, crags and small craters, the things that tip a lander, rather than how steep it is. A cell 1 m above level surroundings has a TRI of 1 m. A smooth slope has a TRI too, about its rise over one cell, so read it together with slopeAt.
- Other definitions are in use. Riley et al. (1999), who named the Terrain Ruggedness Index, leave out the
, which makes theirs times this one; it's the default in gdaldemsince GDAL 3.3. Wilson et al. (2007) take the mean absolute difference instead. Check which one before comparing values. - It compares heights only, so it depends on the cell size: a 1 m grid sees boulders, a 100 m grid only hills.
NaNon the grid's edge and next to a missing cell.
Parameters
| Parameter | Type | Description |
|---|---|---|
grid | GridInterface | Elevation grid, heights in m. |
row | number | Row index, 0 at the north edge (an integer in [0, rows)). |
column | number | Column index, 0 at the west edge (an integer in [0, columns)). |
Returns
number
The TRI in m, or NaN where it can't be computed.
Throws
If row or column is not an integer inside the grid.
Example
ts
// A 2 m boulder on level ground
const grid = createGrid({
rows: 3,
columns: 3,
values: [0, 0, 0, 0, 2, 0, 0, 0, 0],
cellSize: { x: 1, y: 1 }
});
terrainRoughnessIndexAt(grid, 1, 1); // 2See
- terrainRoughnessIndexGrid
- slopeAt
- https://download.osgeo.org/qgis/doc/reference-docs/Terrain_Ruggedness_Index.pdf Riley, DeGloria & Elliot (1999), A Terrain Ruggedness Index that quantifies topographic heterogeneity
- https://gdal.org/en/stable/programs/gdaldem.html gdaldem: the Riley and Wilson definitions