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 |
features |
Vector / list of vectors. Features within |
raster |
spatRaster. Raster template to enable polygon to raster conversion. |
filename |
Character. Path to write stratified raster to disc. |
overwrite |
Logical. Specify whether |
plot |
Logical. Plots output spatRaster. |
details |
Logical. If |
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
)