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

# S4 method for class 'Raster'
names(x)

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

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

Arguments

x

Raster* object

object

Raster* object

value

character (vector)

Value

Character

See also

nlayers, bands

Examples

r <- raster(ncols=5, nrows=5)
values(r) <- 1:ncell(r)
s <- stack(r, r, r)
nlayers(s)
#> [1] 3
names(s)
#> [1] "layer.1" "layer.2" "layer.3"
names(s) <- c('a', 'b', 'c')
names(s)[2] <- 'hello world'
names(s)
#> [1] "a"           "hello.world" "c"          
s
#> 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)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> names      :  a, hello.world,  c 
#> min values :  1,           1,  1 
#> max values : 25,          25, 25 
#> 
labels(s)
#> [1] "a"           "hello.world" "c"