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
polythat will be stratified.- features
Vector / list of vectors. Features within
attributeto 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
filenameshould be overwritten on disc.- plot
Logical. Plots output spatRaster.
- details
Logical. If
FALSE(default) output is spatRaster object of stratified polygon attributes. IfTRUEreturn a list where$outRasteris the stratified attributes,$lookUpis the lookup table for the stratification, andpolyis the defined polygonattributewith correspondingfeatures / strata
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)
#> Reading layer `inventory_polygons' from data source
#> `/home/runner/work/_temp/Library/sgsR/extdata/inventory_polygons.shp'
#> using driver `ESRI Shapefile'
#> Simple feature collection with 632 features and 3 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 431100 ymin: 5337700 xmax: 438560 ymax: 5343240
#> Projected CRS: UTM_Zone_17_Northern_Hemisphere
#--- 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
)
