
Last chance! 50% off unlimited learning
Sale ends in
RasterArray
or SpatialArray
objectExtract subsets of RasterArray
or SpatialArray
class object similarly to a regular array.
# S4 method for XArray
subset(x, i, j, ..., oneDim = FALSE, drop = TRUE)
A RasterLayer
, RasterArray
, Spatial*
or SpatialArray
class object.
RasterArray
or SpatialArray
object.
subscript of the first dimension(rows) or vector-like subsetting.
subscript of the second dimension (columns).
subscript of additional dimensions.
logical
In case of multidimensional RasterArray
s or SpatialArray
s, setting oneDim
to TRUE
allows the application of one dimensional subscripts.
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?
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)
Run the code above in your browser using DataLab