raster (version 1.4-10)

subset: Subset layers in a Raster* object

Description

Extract layers from a RasterStack or RasterBrick object.

Usage

subset(x, ...)

Arguments

x
a RasterStack or RasterBrick object
...
Additional arguments. subset, which should indicate the layers (represented as integer or by their name). drop=TRUE. If TRUE, a selection of a single layer will be returned as a RasterLayer

Value

  • a Raster* object

See Also

dropLayer

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
  s <- stack(r,r,r)
  sel <- subset(s, 2:3)
  sel <- subset(s, 2)
  sel <- subset(s, 2, drop=FALSE)
  
#  sel <- subset(s, 2:3) is equivalent to
  sel <- dropLayer(s, 1)

Run the code above in your browser using DataLab