View source: R/plotting-helpers.R
numLayers | R Documentation |
A unified function for raster::nlayers
, terra::nlyrs
, or lists of these.
Default function returns 1L
for all other classes.
numLayers(x)
x |
An object or list of objects. |
The number of layers in the object.
Eliot McIntire
library(terra)
files <- system.file("maps", package = "quickPlot")
files <- dir(files, full.names = TRUE, pattern = "tif")
maps <- lapply(files, function(x) rast(x))
names(maps) <- sapply(basename(files), function(x) {
strsplit(x, split = "\\.")[[1]][1]
})
stck <- rast(maps)
numLayers(maps)
numLayers(stck)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.