Learn R Programming

chronosphere (version 0.4.1)

[,XArray,ANY,ANY-method: Indexing to extract subsets of a codeRasterArray or SpatialArray object

Description

Single bracket '[' refers to indices and names within the RasterArray . Use double brackets to extract layers based on their names (in the stack).

Usage

# S4 method for XArray,ANY,ANY
[(x, i, j, ..., drop = TRUE)

Value

A RasterLayer, RasterArray, Spatial* or SpatialArray class object.

Arguments

x

RasterArray or SpatialArray object.

i

subscript of the first dimension(rows) or vector-like subsetting.

j

subscript of the second dimension (columns).

...

subscript of additional dimensions.

drop

logical in case the result of subsetting is a single element, should the RasterArray or SpatialArray wrapper be dropped and the element be reduced to a single RasterLayer or Spatial*?

Examples

Run this code
data(dems)
# numeric subsetting
firstThree <- dems[1:3]
# character subsetting
second <- dems["10"]
# logical subsetting
subscript <- rep(FALSE, length(dems))
subscript[2] <- TRUE
second2 <- dems[subscript]
data(coasts)
present<- coasts["0", ]
allMargin <- coasts[, "margin"]

Run the code above in your browser using DataLab