names: Names of raster layers

Description Usage Arguments Value See Also Examples

Description

Get or set the names of the layers of a Raster* object

Usage

1
2
3
4
5
6
7
8
## S4 method for signature 'Raster'
names(x)

## S4 replacement method for signature 'Raster'
names(x)<-value

## S4 method for signature 'Raster'
labels(object)

Arguments

x

Raster* object

object

Raster* object

value

character (vector)

Value

Character

See Also

nlayers, bands

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
r <- raster(ncols=5, nrows=5)
values(r) <- 1:ncell(r)
s <- stack(r, r, r)
nlayers(s)
names(s)
names(s) <- c('a', 'b', 'c')
names(s)[2] <- 'hello world'
names(s)
s
labels(s)

Example output

Loading required package: sp
[1] 3
[1] "layer.1" "layer.2" "layer.3"
[1] "a"           "hello.world" "c"          
class       : RasterStack 
dimensions  : 5, 5, 25, 3  (nrow, ncol, ncell, nlayers)
resolution  : 72, 36  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 
names       :  a, hello.world,  c 
min values  :  1,           1,  1 
max values  : 25,          25, 25 

[1] "a"           "hello.world" "c"          

raster documentation built on Jan. 5, 2021, 3:01 a.m.