subset

0th

Percentile

Subset layers in a Raster* object

Extract a set of layers from a RasterStack or RasterBrick object.

Keywords
spatial
Usage
# S4 method for Raster
subset(x, subset, drop=TRUE, filename='', ...)

# S4 method for RasterStack subset(x, subset, drop=TRUE, filename='', ...)

Arguments
x

RasterBrick or RasterStack object

subset

integer or character. Should indicate the layers (represented as integer or by their name)

drop

If TRUE, a selection of a single layer will be returned as a RasterLayer

filename

character. Output filename (optional)

...

additional arguments as for writeRaster

Value

Raster* object

See Also

dropLayer

Aliases
  • subset
  • subset,Raster-method
  • subset,RasterStack-method
Examples
# NOT RUN {
s <- stack(system.file("external/rlogo.grd", package="raster"))
sel <- subset(s, 2:3)

# Note that this is equivalent to
sel2 <- s[[2:3]]


# and in this particular case:
sel3 <- dropLayer(s, 1)

nlayers(s)
nlayers(sel)

# effect of 'drop=FALSE' when selecting a single layer
sel <- subset(s, 2)
class(sel)
sel <- subset(s, 2, drop=FALSE)
class(sel)
# }
Documentation reproduced from package raster, version 2.9-5, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.