Learn R Programming

terra (version 1.8-80)

replace_layers: Replace layers or variables

Description

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.

Usage

# S4 method for SpatRaster,numeric
[[(x, i) <- value

# S4 method for SpatRaster,character [[(x, i) <- value

# S4 method for SpatVector,numeric [[(x, i) <- value

# S4 method for SpatVector,character [[(x, i) <- value

Arguments

Value

SpatRaster

See Also

$<-, [<-

Examples

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

Run the code above in your browser using DataLab