Learn R Programming

terra (version 1.0-7)

coerce: Coercion of a SpatRaster to other object types

Description

Coercion to other object types

Usage

# S4 method for SpatRaster
as.vector(x, mode='any')

# S4 method for SpatRaster as.matrix(x, wide=FALSE, ...)

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

Arguments

x

SpatRaster or SpatVector

mode

this argument is ignored

wide

logical

...

additional arguments. None implemented

Value

vector, matrix, array

See Also

as.data.frame and as.polygons

Examples

Run this code
# 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)

# }

Run the code above in your browser using DataLab