Learn R Programming

raster (version 1.9-44)

stackSelect: Select cell values from a multi-layer Raster* object

Description

Use a Raster* object to select cell values from different layers in a multi-layer Raster* object. The object to select values y should have cell values between 1 and nlayers(x). The values of y are rounded.

Usage

stackSelect(x, y, ...)

Arguments

x
A RasterStack or RasterBrick object
y
A Raster* object
...
Additional arguments. See below, under Methods

Value

  • A new Raster* object, and in some cases the side effect of a new file on disk.

Methods

The following additional arguments can be passed, to replace default values for this function rll{ recycle Logical. Recursively select values (default = FALSE. Only relevant if y has multiple layers. E.g. if x has 12 layers, and y has 4 layers, the indices of the y layers are used three times type Character. Only relevant when recycle=TRUE. Can be 'index' or 'truefalse'. If it is 'index', the cell values of y should represent layer numbers. If it is 'truefalse' layer numbers are indicated by 0 (not used, NA returned) and 1 (used) filename Character. Output filename. See writeRaster format Character. Output file type. See writeRaster datatype Character. Output data type. See dataType overwrite Logical. If TRUE, "filename" will be overwritten if it exists progress Character. "text", "window", or "" (the default, no progress bar) }

See Also

stackApply

Examples

Run this code
r <- raster(ncol=10, nrow=10)
r[] <- 1
s <- stack(r, r+2, r+5)
r[] <- round((runif(ncell(r)))*3)
x <- stackSelect(s, r)

Run the code above in your browser using DataLab