Coerce a SpatRaster or SpatVector to a data.frame
# S4 method for SpatVector
as.data.frame(x, row.names=NULL, optional=FALSE, geom=NULL, ...)# S4 method for SpatRaster
as.data.frame(x, row.names=NULL, optional=FALSE, xy=FALSE,
cells=FALSE, time=FALSE, na.rm=NA, wide=TRUE, ...)
data.frame
SpatRaster or SpatVector
character or NULL. If not NULL, either "WKT" or "HEX", to get the geometry included in Well-Known-Text or hexadecimal notation. If x
has point geometry, it can also be "XY" to add the coordinates of each point
logical. If TRUE
, the coordinates of each raster cell are included
logical. If TRUE
, the time data is included (if available)
logical. If TRUE
, cells that have a NA
value in at least one layer are removed. If the argument is set to NA
only cells that have NA
values in all layers are removed
logical. If TRUE
, the cell numbers of each raster cell are included
logical. If FALSE
, the data.frame returned has a "long" format
Additional arguments passed to the data.frame
This argument is ignored
This argument is ignored
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
as.data.frame(v)
Run the code above in your browser using DataLab