Learn R Programming

chronosphere (version 0.3.1)

subset,RasterArray-method: Subset a RasterArray object

Description

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

Usage

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

Arguments

x

RasterArray 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, 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 RasterArray wrapper be dropped and the element be reduced to a single RasterLayer?

Value

A RasterLayer or RasterArray class object.

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab