Skip to contents

Derives terrain predictors from a digital elevation model (DEM): slope, northness and eastness, terrain ruggedness, topographic position at one or more radii, its scale-free form (deviation from mean elevation), the topographic wetness index and the heat load index. They complement the climatic indices of climate_indices(): terrain controls the local microclimate, moisture and soil that coarse climate grids miss, and matters most for plants and for fine grains (Schwager & Berg 2021). They are listed in climate_index_names(table = TRUE) under the group "terrain", so climate_index_names("terrain") gives their names and the layers can join any predictor stack for sample_environment() and select_variables().

Usage

topo_indices(
  dem,
  indices = "all",
  radius = c(3, 10),
  radius_unit = c("cells", "km"),
  min_slope = 0.1,
  max_cells = 2e+07,
  path = NULL,
  prefix = "",
  overwrite = FALSE
)

Arguments

dem

Elevation raster (SpatRaster or file path), one layer, in metres. A projected CRS in metres or longitude/latitude.

indices

Which indices: any of "slope", "northness", "eastness", "tri", "tpi", "dev", "twi", "hli", or "all".

radius

Radii of the TPI and DEV windows (one layer each).

radius_unit

"cells" (default) or "km".

min_slope

Smallest slope used in the TWI, degrees.

max_cells

Largest DEM for the TWI (whole raster in memory).

path

Optional folder: each layer is written to <prefix><name>.tif.

prefix

File name prefix.

overwrite

Overwrite existing files?

Value

A SpatRaster with one layer per index (and per radius for TPI and DEV), named as in climate_index_names(table = TRUE) (tpi_<r>, dev_<r>, with r followed by km when radius_unit = "km").

Details

Beyond what terra::terrain() offers, the function gives:

  • TPI at user-chosen radii (one layer per radius, tpi_<r>), in cells or kilometres; kilometres are converted to cells separately in x and y, so the window stays round on longitude/latitude grids.

  • DEV (deviation from mean elevation; De Reu et al. 2013): TPI divided by the standard deviation of elevation in the same window, so a ridge in gentle hills and one in high mountains get comparable values.

  • TWI with its own D8 flow accumulation (terra has none). The upslope area is summed as real cell areas, so it is correct on longitude/latitude grids where cells shrink towards the poles.

  • HLI (McCune & Keon 2002, equation 3) using each cell's own latitude, with aspect folded about the north-east/south-west axis in the northern hemisphere and about the north-west/south-east axis in the southern one, so south-west slopes are warmest in the north and north-west slopes in the south.

  • Northness and eastness weighted by the sine of slope, so they are 0 on flat ground, where aspect has no meaning.

Definitions.

  • slope: steepest gradient (Horn 1981), degrees.

  • northness, eastness: \(\cos(aspect) \sin(slope)\) and \(\sin(aspect) \sin(slope)\), -1 to 1.

  • tri: terrain ruggedness index of Riley et al. (1999), the root of the summed squared elevation differences to the 8 neighbours, in elevation units.

  • tpi_<r>: elevation minus the mean elevation of the cells within radius r (centre excluded; Weiss 2001). Positive on ridges and convex slopes, negative in valleys and hollows, 0 on a plane.

  • dev_<r>: tpi_<r> divided by the standard deviation of elevation in the same window; NA where the window is flat.

  • twi: \(\ln(a / \tan\beta)\) (Beven & Kirkby 1979), with a the upslope area draining through the cell (the cell included) per unit contour width (m), and \(\beta\) the slope; slopes below min_slope (degrees) are raised to it so flats stay finite.

  • hli: potential annual direct incident radiation, MJ cm\(^{-2}\) yr\(^{-1}\), from slope, folded aspect and latitude. The equation was fitted for slopes up to 60 degrees and latitudes 30 to 60 degrees; outside them it extrapolates.

Memory. Slope, aspect, TRI, TPI, DEV and HLI are computed block-wise by terra and can be written straight to disk with path. TWI needs the flow network of the whole DEM in memory, so it stops above max_cells cells: clip the DEM to the study area or aggregate it first.

Assumptions and limits. Every index depends on the resolution and quality of the DEM. TPI and DEV depend on the radii; the TWI on single- direction (D8) flow routing, which concentrates flow in valleys and does not spread it over slopes, and flat areas of a DEM (lakes, artefacts) get arbitrary flow directions; the HLI on the equation of McCune & Keon (2002), fitted for latitudes of 30 to 60 degrees.

References

Beven, K.J., Kirkby, M.J. (1979) A physically based, variable contributing area model of basin hydrology. Hydrological Sciences Bulletin 24, 43-69. doi:10.1080/02626667909491834

De Reu, J., Bourgeois, J., Bats, M., et al. (2013) Application of the topographic position index to heterogeneous landscapes. Geomorphology 186, 39-49. doi:10.1016/j.geomorph.2012.12.015

Guisan, A., Weiss, S.B., Weiss, A.D. (1999) GLM versus CCA spatial modeling of plant species distribution. Plant Ecology 143, 107-122. doi:10.1023/A:1009841519580

Horn, B.K.P. (1981) Hill shading and the reflectance map. Proceedings of the IEEE 69, 14-47. doi:10.1109/PROC.1981.11918

McCune, B., Keon, D. (2002) Equations for potential annual direct incident radiation and heat load. Journal of Vegetation Science 13, 603-606. doi:10.1111/j.1654-1103.2002.tb02087.x

Riley, S.J., DeGloria, S.D., Elliot, R. (1999) A terrain ruggedness index that quantifies topographic heterogeneity. Intermountain Journal of Sciences 5, 23-27.

Schwager, P., Berg, C. (2021) Remote sensing variables improve species distribution models for alpine plant species. Basic and Applied Ecology 54, 1-13. doi:10.1016/j.baae.2021.04.002

Weiss, A.D. (2001) Topographic position and landforms analysis. Poster, ESRI User Conference, San Diego.

See also

climate_indices() for climatic indices; climate_index_names(table = TRUE) for meanings and references.

Examples

# a small synthetic hill
dem <- terra::rast(nrows = 40, ncols = 40, xmin = 0, xmax = 4000,
                   ymin = 0, ymax = 4000, crs = "EPSG:32633")
xy <- terra::xyFromCell(dem, 1:terra::ncell(dem))
terra::values(dem) <- 500 + 300 * exp(-((xy[, 1] - 2000)^2 +
                                        (xy[, 2] - 2000)^2) / 1e6)
ti <- topo_indices(dem, radius = c(3, 8))
names(ti)
#>  [1] "slope"     "northness" "eastness"  "tri"       "tpi_3"     "dev_3"    
#>  [7] "tpi_8"     "dev_8"     "twi"       "hli"      
terra::plot(ti[[c("northness", "tpi_8", "twi", "hli")]])