Last chance! 50% off unlimited learning
Sale ends in
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 SpatRaster
as.polygons(x, trunc=TRUE, dissolve=TRUE, values=TRUE, na.rm=TRUE, extent=FALSE)# S4 method for SpatRaster
as.lines(x)
# S4 method for SpatRaster
as.points(x, values=TRUE, na.rm=TRUE)
# S4 method for SpatVector
as.polygons(x)
# S4 method for SpatVector
as.lines(x)
# S4 method for SpatVector
as.points(x, multi=FALSE, skiplast=TRUE)
# S4 method for SpatExtent
as.polygons(x, crs="")
# S4 method for SpatExtent
as.lines(x, crs="")
# S4 method for SpatExtent
as.points(x, crs="")
SpatRaster or SpatVector
logical; truncate values to integers. Cels with the same value are merged. Therefore, if trunc=FALSE
the object returned can be very large
logical; combine cells with the same values? If TRUE
only the first layer in x
is processed
logical; include cell values as attributes? If FALSE
the cells are not dissolved and the object returned can be very large
logical. If TRUE
a multipoint geometry is returned
logical. If TRUE
the last point of a polygon (which is the same as the first point) is not included
logical. if TRUE
, a polygon for the extent of the SpatRaster is returned. It has vertices for each grid cell, not just the four corners of the raster. This can be useful for more precise projection. In other cases it is better to do as.polygons(ext(x))
to get a much smaller object returned that covers the same extent
logical. If TRUE
cells that are NA
are ignored
character. The coordinate reference system (see crs
SpatVector
# NOT RUN {
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)
}
# }
Run the code above in your browser using DataLab