selectHigh: select cells with high or low values

selectHighestR Documentation

select cells with high or low values

Description

Identify n cells that have the highest of lowest values in the first layer of a SpatRaster.

Usage

## S4 method for signature 'SpatRaster'
selectHighest(x, n, low=FALSE)

Arguments

x

SpatRaster. Only the first layer is processed

n

The number of cells to select

low

logical. If TRUE, the lowest values are selected instead of the highest values

Value

SpatRaster

Examples

f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
x <- selectHighest(r, 1000)
y <- selectHighest(r, 1000, TRUE)

m <- merge(y-1, x)
levels(m) <- data.frame(id=0:1, elevation=c("low", "high"))
plot(m)

rspatial/terra documentation built on Nov. 5, 2024, 5:13 p.m.