nlayers {via}R Documentation

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 signature 'list'
nlayers(x)

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

## S4 method for signature 'VirtualArray'
length(x)

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

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

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.

Value

A numeric value.

Examples

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)


[Package via version 0.2.0 Index]