Skip to contents

Add (in place) a SpatRaster to another SpatRaster. Comparable with c, but without copying the object.

Usage

# S4 method for SpatRaster,SpatRaster
add(x)<-value

# S4 method for SpatRasterDataset,SpatRaster
add(x)<-value

# S4 method for SpatRasterCollection,SpatRaster
add(x)<-value

Arguments

x

SpatRaster, SpatRasterDataset or SpatRasterCollection

value

SpatRaster

See also

Value

SpatRaster

Examples

r <- rast(nrows=5, ncols=9, vals=1:45)
x <- c(r, r*2)
add(x) <- r*3
x
#> class       : SpatRaster 
#> dimensions  : 5, 9, 3  (nrow, ncol, nlyr)
#> resolution  : 40, 36  (x, y)
#> extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) 
#> source(s)   : memory
#> names       : lyr.1, lyr.1, lyr.1 
#> min values  :     1,     2,     3 
#> max values  :    45,    90,   135