nbands
returns the number of bands of the file that a RasterLayer points to (and 1 if it does not point at any file). This functions also works for a RasterStack for which it is equivalent to nlayers
.
band
returns the specific band the RasterLayer refers to (1 if the RasterLayer points at single layer file or does not point at any file).nbands(x)
bandnr(x, ...)
nlayers
f <- system.file("external/rlogo.grd", package="raster")
r <- raster(f, layer=2)
nbands(r)
bandnr(r)
Run the code above in your browser using DataLab