Learn R Programming

terra (version 1.9-46)

varnames: variable and long variable names

Description

Set or get names for each dataset (variable) in a SpatRasterDataset.

Each SpatRaster data source can also have a variable name and a long variable name. They are set when reading a file with possibly multiple sub-datasets (e.g. NetCDF or HDF5 format) into a single SpatRaster. Each sub-dataset is a separate "data-source" in the SpatRaster. Note that newly created or derived SpatRasters always have a single variable (data source), and therefore the variable names are lost when processing a multi-variable SpatRaster. Thus the variable names are mostly useful to understand a SpatRaster created from some files and for managing SpatRasterDatasets.

See names for the more commonly used layer names.

Usage

# S4 method for SpatRaster
varnames(x)

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

# S4 method for SpatRaster longnames(x)

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

# S4 method for SpatRasterDataset varnames(x)

# S4 method for SpatRasterDataset varnames(x)<-value

# S4 method for SpatRasterDataset longnames(x)

# S4 method for SpatRasterDataset longnames(x)<-value

Value

character

Arguments

x

SpatRaster, SpatRasterDataset

value

character (vector)

Examples

Run this code
s <- rast(ncols=5, nrows=5, nlyrs=3)
names(s) <- c("a", "b", "c")
x <- sds(s, s)
varnames(x) <- c("one", "two")
x

Run the code above in your browser using DataLab