Learn R Programming

terra (version 1.5-34)

as.list: SpatRaster or SpatVector to list

Description

Coerce a SpatRaster, SpatRasterCollection, or SpatVector to a list. With a SpatRaster, each layer becomes a list element. With a SpatRasterCollection, each SpatRaster becomes a list element. With a SpatVector, each variable (attribute) becomes a list element.

Usage

# S4 method for SpatRaster
as.list(x, ...)

# S4 method for SpatRasterCollection as.list(x, ...)

# S4 method for SpatVector as.list(x, geom=NULL, ...)

Arguments

x

SpatRaster or SpatVector

geom

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 bey "XY" to add the coordinates of each point

...

Additional arguments. These are ignored

Value

list

See Also

see coerce for as.data.frame with a SpatRaster; and geom to only extract the geometry of a SpatVector

Examples

Run this code
# NOT RUN {
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
as.list(v)
# }

Run the code above in your browser using DataLab