strat_map {sgsR}R Documentation

Map a raster stack of a list of rasters

Description

Map stratified rasters to a combined stratification.

Usage

strat_map(
  sraster,
  stack = FALSE,
  filename = NULL,
  overwrite = FALSE,
  plot = FALSE,
  details = FALSE
)

Arguments

sraster

spatRaster or list. Stratification raster stack or list of rasters. If sraster is of class list, then it is internally converted into a raster stack.

stack

Logical. Default = FALSE. If TRUE, inputs and output will be stacked: strata_1, strata_2, ..., strata.

filename

Character. Path to write stratified raster to disc.

overwrite

Logical. Specify whether filename should be overwritten on disc.

plot

Logical. Plots output strata raster and visualized strata with boundary dividers.

details

Logical. If FALSE (default) output is a mapped stratified spatRaster object. If TRUE return a list where $outRaster is the mapped stratified raster, and $lookUp is the lookup table for the stratification.

Value

A spatRaster object.

Mapping

The mapping algorithm will take the stratification from sraster and combine it with overlying strata values across all layers. This will result in a strata attribute where the values from all inputs are combined.

i.e.

If strata_1 = 1 and strata_2 = 1 then strata = 11.

If strata_1 = 2 and strata_2 = 14 then strata = 214.

If strata_1 = "A" and strata_2 = 14 then strata = "A14".

Author(s)

Tristan R.H. Goodbody, Tommaso Trotto, Robert Hijmans

See Also

Other stratify functions: strat_breaks(), strat_kmeans(), strat_poly(), strat_quantiles()

Examples

#--- load input metrics rasters ---#
raster <- system.file("extdata", "sraster.tif", package = "sgsR")
sraster <- terra::rast(raster)

#--- read polygon coverage ---#
poly <- system.file("extdata", "inventory_polygons.shp", package = "sgsR")
fri <- sf::st_read(poly)

#--- stratify polygon coverage ---#
#--- specify polygon attribute to stratify ---#

attribute <- "NUTRIENTS"

#--- specify features within attribute & how they should be grouped ---#
#--- as a single vector ---#

features <- c("poor", "rich", "medium")

srasterfri <- strat_poly(
  poly = fri,
  attribute = attribute,
  features = features,
  raster = sraster
)

#--- map srasters with raster stack ---#
stack <- c(srasterfri, sraster)
strat_map(
  sraster = stack
)

#--- map sraster with list of rasters ---#
rast_list <- list(srasterfri, sraster)
strat_map(
  sraster = rast_list,
  stack = TRUE,
  details = TRUE
)

[Package sgsR version 1.4.5 Index]