Learn R Programming

via (version 0.2.0)

nlayers: Number of elements or layers in a 'VirtualArray'-derived class object

Description

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

Usage

nlayers(x)

# S4 method for list nlayers(x)

# S4 method for SpatRaster nlayers(x)

# S4 method for VirtualArray length(x)

# S4 method for XArray nlayers(x)

# S4 method for RasterArray nlayers(x)

Value

A numeric value.

Arguments

x

a VirtualArray-derived 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. As the object can contain missing values, the number of actual layers can be queried with nlayers.

Examples

Run this code
ex <- rastex()
# omit third element
ex[3] <- NA
# number of elements in the RasterArray
length(ex)
# remaining number values in the stack 
length(ex@stack)
# the number of remaining layers in the RasterArray
nlayers(ex)

Run the code above in your browser using DataLab