
Coerce a SpatRaster, SpatRasterCollection, SpatRasterDataset, SpatVector or SpatVectorCollection to a list. With a SpatRaster, each layer becomes a list element. With a SpatRasterCollection or SpatRasterDataset, each SpatRaster becomes a list element. With a SpatVector, each variable (attribute) becomes a list element. With a SpatVectorCollection, each SpatVector becomes a list element.
# S4 method for SpatRaster
as.list(x, geom=NULL, ...)# S4 method for SpatRasterCollection
as.list(x, ...)
# S4 method for SpatVector
as.list(x, geom=NULL, ...)
# S4 method for SpatVectorCollection
as.list(x, ...)
list
SpatRaster, SpatRasterDataset, SpatRasterCollection, or SpatVector
character or NULL. If not NULL, and x
is a SpatVector, it should be either "WKT" or "HEX", to get the geometry included in Well-Known-Text or hexadecimal notation. If x
has point geometry, it can also bey "XY" to add the coordinates of each point. If x
is a SpatRaster, any value that is not NULL will return a list with the the parameters describing the geometry of the SpatRaster are returned
additional arguments. These are ignored
see coerce
for as.data.frame
with a SpatRaster; and geom
to only extract the geometry of a SpatVector
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
as.list(v)
s <- rast(system.file("ex/logo.tif", package="terra")) + 1
as.list(s)
Run the code above in your browser using DataLab