Learn R Programming

quickPlot (version 0.1.1)

numLayers: Find the number of layers in a Spatial Object

Description

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.

Usage

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)

Arguments

x

A .quickPlotObjects object or list of these.

Value

The number of layers in the object.

Examples

Run this code
# NOT RUN {
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)
numLayers(stck)

# }

Run the code above in your browser using DataLab