Learn R Programming

terra (version 0.2-6)

names: Names of Spat* objects

Description

Get or set the names of the layers of a SpatRaster.

Usage

# S4 method for SpatRaster
names(x)
# S4 method for SpatRaster
names(x)<-value

Arguments

x

For names: SpatRaster. For validNames: character

value

character (vector)

Value

Character

Examples

Run this code
# NOT RUN {
s <- rast(ncols=5, nrows=5, nlyr=3)
nlyr(s)
names(s)
names(s) <- c('a', 'b', 'c')
# space is not valid
names(s)[2] <- 'hello world'
names(s)

# two invalid names
names(s) <- c('a', '  a  ', '3')
s

# }

Run the code above in your browser using DataLab