Learn R Programming

spatialEco (version 0.1-4)

tri: Terrain Ruggedness Index

Description

Implementation of the Riley et al (1999) Terrain Ruggedness Index

Usage

tri(r, s = 3, exact = TRUE, file.name = NULL, ...)

Arguments

r
raster class object
s
Scale of window. Must be odd number, can represent 2 dimensions (eg., s=c(3,5) would represent a 3 x 5 window)
exact
Calculate (TRUE/FALSE) the exact TRI or an algebraic approximation.
file.name
Name of output raster (optional)
...
Additional arguments passed to writeRaster

Value

  • raster class object or raster written to disk

References

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

Examples

Run this code
library(raster)
 r <- raster(nrows=180, ncols=360, xmn=571823.6, xmx=616763.6, ymn=4423540, 
             ymx=4453690, resolution=270, crs = CRS("+proj=utm +zone=12 +datum=NAD83 
             +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"))
   r[] <- runif(ncell(r), 1000, 5000) 
   r <- focal(r, w=matrix(1/121,nrow=11,ncol=11)) 
    
  ( tri.ext <- tri(r) )
  ( tri.app <- tri(r, exact = FALSE) )
  plot(stack(tri.ext, tri.app))

Run the code above in your browser using DataLab