There are already methods for Raster*
in the raster package.
Adding methods for list
, SpatialPolygons
, SpatialLines
,
and SpatialPoints
, gg
, histogram
, igraph
.
These latter classes return 1
.
numLayers(x) # S4 method for list numLayers(x) # S4 method for .quickPlot numLayers(x) # S4 method for Raster numLayers(x) # S4 method for Spatial numLayers(x) # S4 method for ANY numLayers(x)
x | A |
---|
The number of layers in the object.
library(igraph) library(raster) files <- system.file("maps", package = "quickPlot") %>% dir(., full.names = TRUE, pattern = "tif") maps <- lapply(files, function(x) raster(x)) names(maps) <- sapply(basename(files), function(x) { strsplit(x, split = "\\.")[[1]][1] }) stck <- stack(maps) numLayers(maps)#> [1] 5numLayers(stck)#> [1] 5