During the transition from raster to terra, some functions are not drop in
replacements, such as minValue and maxValue became terra::minmax. This
helper allows one function to be used, which calls the correct max or min
function, depending on whether the object is a Raster or SpatRaster.
minFn(x)
maxFn(x)
dataType2(x, ...)
nlayers2(x)
values2(x, ...)A vector (not matrix as in terra::minmax) with the minimum or maximum
value on the Raster or SpatRaster, one value per layer.
if (requireNamespace("terra", quietly = TRUE)) {
ras <- terra::rast(terra::ext(0, 10, 0, 10), vals = 1:100)
maxFn(ras)
minFn(ras)
}
#> [1] 1