Learn R Programming

terra (version 1.7-83)

extremes: Get or compute the minimum and maximum cell values

Description

The minimum and maximum value of a SpatRaster are returned or computed (from a file on disk if necessary) and stored in the object.

Usage

# S4 method for SpatRaster
minmax(x, compute=FALSE)
# S4 method for SpatRaster
hasMinMax(x)
# S4 method for SpatRaster
setMinMax(x, force=FALSE)

Value

minmax: numeric matrix of minimum and maximum cell values by layer

hasMinMax: logical indicating whether the min and max values are available.

setMinMax: nothing. Used for the side-effect of computing the minimum and maximum values of a SpatRaster

Arguments

x

SpatRaster

compute

logical. If TRUE min and max values are computed if they are not available

force

logical. If TRUE min and max values are recomputed even if already available

Examples

Run this code
r <- rast(system.file("ex/elev.tif", package="terra"))
minmax(r)

Run the code above in your browser using DataLab