Learn R Programming

chronosphere (version 0.3.1)

length,RasterArray-method: Number of elements or layers in a RasterArray class object

Description

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

Usage

# S4 method for RasterArray
length(x)

# S4 method for RasterArray nlayers(x)

Arguments

x

a RasterArray class object.

Value

A numeric value.

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
# NOT RUN {
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