arraylength: Number of elements or layers in a 'RasterArray' or...

Description Usage Arguments Details Value Examples

Description

Function to return the length of the array in which RasterLayers are organized.

Usage

1
2
3
4
5
6
7
8
## S4 method for signature 'XArray'
length(x)

## S4 method for signature 'XArray'
nlayers(x)

## S4 method for signature 'SpatialStack'
nlayers(x)

Arguments

x

a RasterArray or SpatialArray class object.

Details

The length() function returns the number elements that should be present based on the array structure itself, and not the total number of values stored in the object (such as the length method of RasterStacks). As the object can contain missing values, the number of actual layers can be queried with nlayers.

Value

A numeric value.

Examples

1
2
3
4
5
6
7
8
9
data(dems)
# omit third element
dems[3] <- NA
# number of elements in the RasterArray
length(dems)
# remaining number values in the stack 
length(dems@stack)
# the number of remaining layers in the RasterArray
nlayers(dems)

chronosphere documentation built on April 19, 2021, 1:07 a.m.