Learn R Programming

terra (version 1.7-55)

concats: Concatenate categorical rasters

Description

Combine two categorical rasters by concatenating their levels.

Usage

# S4 method for SpatRaster
concats(x, y, filename="", ...)

Value

SpatRaster

Arguments

x

SpatRaster (with a single, categorical, layer)

y

SpatRaster (with a single, categorical, layer)

filename

character. Output filename

...

additional arguments for writing files as in writeRaster

See Also

cats

Examples

Run this code
set.seed(0)
r <- rast(nrows=10, ncols=10)
values(r) <- sample(3, ncell(r), replace=TRUE)
levels(r) <- data.frame(id=1:3, cover=c("forest", "water", "urban"))

rr <- rast(r)
values(rr) <- sample(1:3, ncell(rr), replace=TRUE)
levels(rr) <- data.frame(id=c(1:3), color=c("red", "green", "blue"))

x <- concats(r, rr)
x
levels(x)[[1]]

Run the code above in your browser using DataLab