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

subset-XArray-method

Subset a RasterArray or SpatialArray object


Description

Extract subsets of RasterArray or SpatialArray class object similarly to a regular array.

Usage

## S4 method for signature 'XArray'
subset(x, i, j, ..., oneDim = FALSE, drop = TRUE)

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.

oneDim

logical In case of multidimensional RasterArrays or SpatialArrays, setting oneDim to TRUE allows the application of one dimensional subscripts.

drop

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

Value

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

Examples

data(dems)
# first 4
subset(dems, i=1:4)
# missing at the end
subset(dems, i=1:12)
# character subscript
subset(dems, i=c("5", "25"))
# logical subscript
subs <- rep(TRUE, length(dems))
subs[1] <- FALSE # remove first
subset(dems, i= subs)
# no drop
subset(dems, i=1, drop=FALSE)
data(coasts)
subset(coasts, i=2, j=1:2)

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.