xrspatial.terrain_metrics.tri#
- xrspatial.terrain_metrics.tri(agg: DataArray, name: str | None = 'tri', boundary: str = 'nan') DataArray[source]#
Compute the Terrain Ruggedness Index (TRI) for each cell.
TRI quantifies local elevation variation as the square root of the sum of squared differences between the center cell and its 8 neighbors in a 3x3 window (Riley et al. 1999).
- Parameters:
agg (xarray.DataArray or xr.Dataset) – 2D NumPy, CuPy, NumPy-backed Dask, or CuPy-backed Dask xarray DataArray of elevation values. If a Dataset is passed, the operation is applied to each data variable independently.
name (str, default='tri') – Name of output DataArray.
boundary (str, default='nan') – How to handle edges where the kernel extends beyond the raster.
'nan'- fill missing neighbours with NaN (default).'nearest'- repeat edge values.'reflect'- mirror at boundary.'wrap'- periodic / toroidal.
- Returns:
2D array of TRI values with the same shape, coords, dims, and attrs as the input.
- Return type:
xarray.DataArray or xr.Dataset
References
Riley, S.J., DeGloria, S.D. and Elliot, R. (1999). A Terrain Ruggedness Index that Quantifies Topographic Heterogeneity. Intermountain Journal of Sciences, 5(1-4), 23-27.