as.spatvector {terra} | R Documentation |
Conversion of a SpatRaster or SpatExtent to a SpatVector of points, lines, or polygons;
And conversion of a SpatVector to a another SpatVector type.
## S4 method for signature 'SpatRaster'
as.polygons(x, trunc=TRUE, dissolve=TRUE, values=TRUE,
na.rm=TRUE, na.all=FALSE, extent=FALSE)
## S4 method for signature 'SpatRaster'
as.lines(x)
## S4 method for signature 'SpatRaster'
as.points(x, values=TRUE, na.rm=TRUE, na.all=FALSE)
## S4 method for signature 'SpatVector'
as.polygons(x)
## S4 method for signature 'SpatVector'
as.lines(x)
## S4 method for signature 'SpatVector'
as.points(x, multi=FALSE, skiplast=TRUE)
## S4 method for signature 'SpatExtent'
as.polygons(x, crs="")
## S4 method for signature 'SpatExtent'
as.lines(x, crs="")
## S4 method for signature 'SpatExtent'
as.points(x, crs="")
x |
SpatRaster or SpatVector |
trunc |
logical; truncate values to integers. Cels with the same value are merged. Therefore, if |
dissolve |
logical; combine cells with the same values? If |
values |
logical; include cell values as attributes? If |
multi |
logical. If |
skiplast |
logical. If |
extent |
logical. if |
na.rm |
logical. If |
na.all |
logical. If |
crs |
character. The coordinate reference system (see |
SpatVector
r <- rast(ncols=2, nrows=2)
values(r) <- 1:ncell(r)
as.points(r)
as.lines(ext(r), crs=crs(r))
if (gdal() >= "3.0.0") {
p <- as.polygons(r)
p
as.lines(p)
as.points(p)
}