replace_layers | R Documentation |
Replace the layers of SpatRaster with (layers from) another SpatRaster or replace variables of a SpatVector. You can also create new layers/variables with these methods.
## S4 replacement method for signature 'SpatRaster,numeric'
x[[i]] <- value
## S4 replacement method for signature 'SpatRaster,character'
x[[i]] <- value
## S4 replacement method for signature 'SpatVector,numeric'
x[[i]] <- value
## S4 replacement method for signature 'SpatVector,character'
x[[i]] <- value
x |
SpatRaster or SpatVector |
i |
if |
value |
if |
SpatRaster
$<-, [<-
# raster
s <- rast(system.file("ex/logo.tif", package="terra"))
s[["red"]] <- mean(s)
s[[2]] <- sqrt(s[[1]])
# vector
v <- vect(system.file("ex/lux.shp", package="terra"))
v[["ID_1"]] <- 12:1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.