Learn R Programming

raster (version 2.3-40)

which.min: Where is the min or max value?

Description

Which cells have the minumum / maximum value (for a RasterLayer), or which layer has the minimum/maximum value (for a RasterStack or RasterBrick)?

Usage

which.min(x)
which.max(x)

Arguments

x
Raster* object

Value

  • vector of cell numbers (if x is a RasterLayer) or (if x is a RasterStack or RasterBrick) a RasterLayer giving the number of the first layer with the minimum or maximum value for a cell

See Also

Which

Examples

Run this code
b <- brick(system.file("external/rlogo.grd", package="raster")) 

r <- which.min(b)

i <- which.min(b[[3]])
xy <- xyFromCell(b, i)
plot(b[[3]])
points(xy)

Run the code above in your browser using DataLab