Learn R Programming

terra (version 0.5-2)

unique: Unique values

Description

This function returns the unique values in a SpatRaster.

Usage

# S4 method for SpatRaster
unique(x, incomparables=FALSE, ...)

Arguments

x

SpatRaster

incomparables

logical. If TRUE, the unique values are determined for all layers together, and the result is a matrix. If FALSE, each layer is evaluated separately, and a list is returned.

...

additional arguments. none implemented

Value

vector or matrix

Examples

Run this code
# NOT RUN {
r <- rast(ncol=5, nrow=5)
values(r) <- rep(1:5, each=5)
unique(r)
s <- c(r, round(r/3))
unique(s)
unique(s,TRUE)
# }

Run the code above in your browser using DataLab