Learn R Programming

raster (version 1.8-3)

subset: Subset layers in a Raster* object

Description

Extract layers from a Raster* object.

Usage

subset(x, ...)

Arguments

x
Raster 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

  • 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