Skip to contents

Terrain Ruggedness Index is a measurement developed by Riley, et al. (1999). The elevation difference between the centre pixel and its eight immediate pixels are squared and then averaged and its square root is taken to get the TRI value. This function allows to efficiently calculate terrain ruggedness index (tri) statistics for polygons. For each polygon, the desired statistic/s (mean, median or sd) is/are returned. The required resources for this indicator are:

Format

A tibble with a column for terrain ruggedness index statistics (in meters). The range of index values and corresponding meaning: (1) 0 - 80 m :- level surface (2) 81-116 m :- nearly level surface (3) 117-161 m :- slightly rugged surface (4) 162-239 m :- intermediately rugged surface (5) 240-497 m :- moderately rugged surface (6) 498-958 m :- highly rugged surface (7) 959-4367 m:- extremely rugged surface

Details

The following arguments can be set:

stats_tri

Function to be applied to compute statistics for polygons either single or multiple inputs as character. Supported statistics are: "mean", "median", "sd", "min", "max", "sum" "var".

engine

The preferred processing functions from either one of "zonal", "extract" or "exactextract" as character.

References

Riley, S. J., DeGloria, S. D., & Elliot, R. (1999). Index that quantifies topographic heterogeneity. intermountain Journal of sciences, 5(1-4), 23-27.

Examples

if (Sys.getenv("NOT_CRAN") == "true") {
  library(sf)
  library(mapme.biodiversity)

  temp_loc <- file.path(tempdir(), "mapme.biodiversity")
  if (!file.exists(temp_loc)) {
    dir.create(temp_loc)
    resource_dir <- system.file("res", package = "mapme.biodiversity")
    file.copy(resource_dir, temp_loc, recursive = TRUE)
  }

  (try(aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg",
    package = "mapme.biodiversity"
  ) %>%
    read_sf() %>%
    init_portfolio(
      years = 2000:2020,
      outdir = file.path(temp_loc, "res"),
      tmpdir = tempdir(),
      add_resources = FALSE,
      verbose = FALSE
    ) %>%
    get_resources("nasa_srtm") %>%
    calc_indicators("tri", stats_tri = c("mean", "median", "sd", "var"), engine = "extract") %>%
    tidyr::unnest(tri)))
}
#> Error in map(.x, .f, ...) :  In index: 4.
#> Caused by error:
#> ! [extract] not a valid function
#> Warning: Error occured at polygon 1 with the following error message: Error in map(.x, .f, ...) :  In index: 4.
#> Caused by error:
#> ! [extract] not a valid function
#> . 
#>  Returning NAs.
#> Simple feature collection with 1 feature and 6 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -71.80933 ymin: 18.57668 xmax: -71.33201 ymax: 18.69931
#> Geodetic CRS:  WGS 84
#> # A tibble: 1 × 7
#>   WDPAID NAME            DESIG_ENG ISO3  assetid value                      geom
#>    <dbl> <chr>           <chr>     <chr>   <int> <lgl>             <POLYGON [°]>
#> 1 478140 Sierra de Neiba National… DOM         1 NA    ((-71.76134 18.66333, -7…