Learn R Programming

chronosphere (version 0.4.1)

length,XArray-method: 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 XArray
length(x)

# S4 method for XArray nlayers(x)

# S4 method for SpatialStack nlayers(x)

Value

A numeric value.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab