| selectHighest | R Documentation |
Identify the cells that have the n highest or lowest values in the first layer of a SpatRaster.
With ties="first" (the default), exactly n cells are selected; ties are broken by choosing the smallest cell numbers. With ties="all", all cells that have one of the n highest or lowest values are selected, so the number of TRUE cells can be larger than n when there are ties (as is common with integer data).
## S4 method for signature 'SpatRaster'
selectHighest(x, n, low=FALSE, ties="first", filename="", ...)
x |
SpatRaster. Only the first layer is processed |
n |
positive integer. The number of highest or lowest values to select |
low |
logical. If |
ties |
character. Either |
filename |
character. Output filename |
... |
additional arguments for writing files as in |
SpatRaster
where.max, where.min, ifel, selectSize
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.