Skip to contents

Turns the cells of chosen classes of a categorical raster into polygons, e.g. Mediterranean and arid Koppen-Geiger climates to test how much M changes without them (pass the result to exclude in delimit_m() or m_scenarios()).

Usage

class_polygons(raster, classes, labels = NULL, fact = 1)

Arguments

raster

Categorical raster.

classes

Class values, or labels if labels is given.

labels

Optional class labels indexed by class value.

fact

Aggregation factor (modal) to simplify the polygons.

Value

An sf object with one (multi)polygon.

Examples

r <- terra::rast(nrows = 10, ncols = 10, vals = rep(1:2, 50))
class_polygons(r, 2)
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -144 ymin: -90 xmax: 180 ymax: 90
#> Geodetic CRS:  WGS 84 (CRS84)
#>                         geometry
#> 1 MULTIPOLYGON (((-108 -90, -...