Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sub-sub-XArray-ANY-ANY-method

Indexing to extract RasterLayers of a RasterArray or Spatial* of a SpatialArray object


Description

Double bracket '[[' refers to layers' name in the RasterStack of the RasterArray or the SpatialStack of the SpatialArray. Use single brackets to extract elements based on their position in the RasterArray or SpatialArray

Usage

## S4 method for signature 'XArray,ANY,ANY'
x[[i, drop = TRUE]]

Arguments

x

RasterArray or SpatialArray object.

i

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

drop

logical should the RasterStack be dropped and the element be reduced to a single RasterLayer?

Value

A RasterLayer or RasterArray class object.

Examples

data(dems)
# finds a layer
dems[["dem_30"]]
# returns a stack
dems[[c("dem_0", "dem_15")]]
# replaces a layervalues, but not the attributes of the layer
dem2 <- dems
dem2[["dem_0"]] <- dem2[["dem_5"]]
# compare every value in the 0 and 5 ma maps, they are all the same
mean(values(dem2[["dem_0"]]==dem2[["dem_5"]]))

chronosphere

Earth System History Variables

v0.4.1
CC BY 4.0
Authors
Adam T. Kocsis, Nussaibah B. Raja
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.