addLayer: Add or drop a layer

Description Usage Arguments Value See Also Examples

Description

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).

Usage

1
2

Arguments

x

Raster* object

i

integer. Indices of the layers to be dropped

...

Additional arguments. The layers to add for addLayer. None implemented for dropLayer)

Value

RasterStack

See Also

subset

Examples

1
2
3
4
5
6
7
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)

Example output

Loading required package: sp
class       : RasterStack 
dimensions  : 115, 80, 9200, 5  (nrow, ncol, ncell, nlayers)
resolution  : 40, 40  (x, y)
extent      : 178400, 181600, 329400, 334000  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:28992 +towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812 +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs 
names       : test.1.1, test.2.1,  test.3, test.1.2, test.2.2 
min values  :  128.434,  128.434, 128.434,   64.217,  256.868 
max values  :  1805.78,  1805.78, 1805.78,   902.89,  3611.56 

[1] 3

raster documentation built on Jan. 5, 2021, 3:01 a.m.