as.polygons,GRaster-method {fasterRaster} | R Documentation |
Convert a raster to a polygons vector
Description
as.polygons()
converts a GRaster
to a "polygons" GVector
. After running this function, geometry cleaning may be useful to use to "tidy up" the vector.
Usage
## S4 method for signature 'GRaster'
as.polygons(x, round = TRUE, smooth = FALSE)
Arguments
x |
A |
round |
Logical: If |
smooth |
Logical: If |
Value
A GVector
.
See Also
as.points()
, as.lines()
, terra::as.polygons()
, geometry cleaning, and GRASS tool r.to.vect
Examples
if (grassStarted()) {
# Setup
library(terra)
# Elevation
madElev <- fastData("madElev")
# Convert SpatRaster to GRaster:
elev <- fast(madElev)
# To speed things up, first group cells of similar value:
elevClumps <- clump(elev, minDiff = 0.0115)
# Convert to polygons:
rastToPolys <- as.polygons(elevClumps)
plot(rastToPolys)
}
[Package fasterRaster version 8.4.1.0 Index]