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

arraylength

Number of elements or layers in a RasterArray or SpatialArray class object


Description

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

Usage

## 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

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

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.