as.polygons {terra} | R Documentation |
Conversion to a SpatVector of polygons
Description
Conversion of a SpatRaster, SpatVector or SpatExtent to a SpatVector of polygons.
Usage
## S4 method for signature 'SpatRaster'
as.polygons(x, round=TRUE, aggregate=TRUE, values=TRUE,
na.rm=TRUE, na.all=FALSE, extent=FALSE, digits=0, ...)
## S4 method for signature 'SpatVector'
as.polygons(x, extent=FALSE)
## S4 method for signature 'SpatExtent'
as.polygons(x, crs="")
Arguments
x |
SpatRaster, SpatVector or SpatExtent |
round |
logical; If |
aggregate |
logical; combine cells with the same values? If |
values |
logical; include cell values as attributes? |
extent |
logical. if |
na.rm |
logical. If |
na.all |
logical. If |
digits |
integer. The number of digits for rounding (if |
crs |
character. The coordinate reference system (see |
... |
additional arguments. For backward compatibility. Will be removed in the future |
Value
SpatVector
See Also
Examples
r <- rast(ncols=2, nrows=2)
values(r) <- 1:ncell(r)
if (gdal() >= "3.0.0") {
p <- as.polygons(r)
p
}