extremeValues

0th

Percentile

Minimum and maximum values

Returns the minimum or maximum value of a RasterLayer or layer in a RasterStack

Keywords
spatial
Usage
minValue(x, ...)
maxValue(x, ...)
Arguments
x
RasterLayer or RasterStack object
...
Additional argument: layer number (for RasterStack or RasterBrick objects)
Details

If a Raster* object is created from a file on disk, the min and max values are often not known (depending on the file format). You can use setMinMax to set them in the Raster* object.

Value

  • a number

Aliases
  • minValue
  • maxValue
  • minValue,RasterLayer-method
  • minValue,RasterStack-method
  • minValue,RasterBrick-method
  • maxValue,RasterLayer-method
  • maxValue,RasterStack-method
  • maxValue,RasterBrick-method
Examples
r <- raster()
r <- setValues(r, 1:ncell(r))
minValue(r)
maxValue(r)
r <- setValues(r, round(100 * runif(ncell(r)) + 0.5))
minValue(r)
maxValue(r)

r <- raster(system.file("external/test.grd", package="raster"))
# this raster is from an 'external' format, so min and maxValue are not known
minValue(r)
maxValue(r)

r1 <- setMinMax(r)
# now they are known:
minValue(r1)
maxValue(r1)

r2 <- readAll(r)
# now they are known too:
minValue(r2)
maxValue(r2)
Documentation reproduced from package raster, version 1.0.0-1, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.