strat_poly {sgsR}R Documentation

Stratify using polygons

Description

Stratify based on polygon coverage attributes and features.

Usage

strat_poly(
  poly,
  attribute,
  features,
  raster,
  filename = NULL,
  overwrite = FALSE,
  plot = FALSE,
  details = FALSE
)

Arguments

poly

sf. Input polygon coverage. e.g. - forest resources inventory coverage.

attribute

Character. Name of attribute within poly that will be stratified.

features

Vector / list of vectors. Features within attribute to guide stratification.

raster

spatRaster. Raster template to enable polygon to raster conversion.

filename

Character. Path to write stratified raster to disc.

overwrite

Logical. Specify whether filename should be overwritten on disc.

plot

Logical. Plots output spatRaster.

details

Logical. If FALSE (default) output is spatRaster object of stratified polygon attributes. If TRUE return a list where $outRaster is the stratified attributes, $lookUp is the lookup table for the stratification, and poly is the defined polygon attribute with corresponding features / strata

Value

A spatRaster object.

Author(s)

Tristan R.H. Goodbody

See Also

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

Examples

#--- load input metrics raster ---#
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")

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

#--- or as multiple lists ---#

g1 <- "poor"
g2 <- c("rich", "medium")

features <- list(g1, g2)

srasterpoly <- strat_poly(
  poly = fri,
  attribute = attribute,
  features = features,
  raster = sraster,
  details = TRUE
)

[Package sgsR version 1.4.5 Index]