
Last chance! 50% off unlimited learning
Sale ends in
Coercion to other object types or other vector types
# S4 method for SpatRaster
as.vector(x, mode='any')# S4 method for SpatRaster
as.matrix(x, wide=FALSE, ...)
# S4 method for SpatRaster
as.data.frame(x, xy=FALSE, cells=FALSE, ...)
# S4 method for SpatRaster
as.array(x, ...)
# S4 method for SpatRaster
as.polygons(x, trunc=TRUE, dissolve=TRUE, values=TRUE, extent=FALSE, ...)
# S4 method for SpatExtent
as.polygons(x, crs="", ...)
# S4 method for SpatRaster
as.points(x, values=TRUE, ...)
# S4 method for SpatVector
as.lines(x, ...)
# S4 method for SpatVector
as.points(x, ...)
SpatRaster or SpatVector
logical
logical
logical
this argument is ignored
logical; truncate values to integers. If FALSE
the object returned can be very large
logical; combine cells with the same values?
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 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
character. The coordinate reference system
additional arguments. None implemented
vector, matrix, array, data.frame or SpatVector
# NOT RUN {
r <- rast(ncol=2, nrow=2)
values(r) <- 1:ncell(r)
as.vector(r)
as.matrix(r)
as.matrix(r, wide=TRUE)
as.data.frame(r, xy=TRUE)
as.array(r)
as.points(r)
if (gdal_version() >= "3.0.0") {
p <- as.polygons(r)
p
as.lines(p)
as.points(p)
}
# }
Run the code above in your browser using DataLab