subset | R Documentation |
Extract a set of layers from a RasterStack or RasterBrick object.
## S4 method for signature 'Raster'
subset(x, subset, drop=TRUE, filename='', ...)
## S4 method for signature 'RasterStack'
subset(x, subset, drop=TRUE, filename='', ...)
x |
RasterBrick or RasterStack object |
subset |
integer or character. Should indicate the layers (represented as integer or by their name) |
drop |
If |
filename |
character. Output filename (optional) |
... |
additional arguments as for |
Raster* object
dropLayer
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.