selectHighest | R Documentation |
Identify n cells that have the highest of lowest values in the first layer of a SpatRaster.
## S4 method for signature 'SpatRaster'
selectHighest(x, n, low=FALSE)
x |
SpatRaster. Only the first layer is processed |
n |
The number of cells to select |
low |
logical. If |
SpatRaster
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.