
Last chance! 50% off unlimited learning
Sale ends in
Add a layer to a Raster* object or drop a layer from a RasterStack or RasterBrick. The object returned is always a RasterStack (unless nothing to add or drop was provided, in which case the original object is returned).
addLayer(x, ...)
dropLayer(x, i, ...)
RasterStack
Raster* object
integer. Indices of the layers to be dropped
Additional arguments. The layers to add for addLayer. None implemented for dropLayer)
file <- system.file("external/test.grd", package="raster")
s <- stack(file, file, file)
r <- raster(file)
s <- addLayer(s, r/2, r*2)
s
s <- dropLayer(s, c(3, 5))
nlayers(s)
Run the code above in your browser using DataLab