powered by
Identify n cells that have the highest of lowest values in the first layer of a SpatRaster.
# S4 method for SpatRaster selectHighest(x, n, low=FALSE)
SpatRaster. Only the first layer is processed
The number of cells to select
logical. If TRUE, the lowest values are selected instead of the highest values
TRUE
SpatRaster
# NOT RUN { 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) <- c("low", "high") plot(m) # }
Run the code above in your browser using DataLab