normalize_minmax: Normalize data using min-max rescaling

View source: R/normalize_minmax.R

normalize_minmaxR Documentation

Normalize data using min-max rescaling

Description

Rescale numeric or raster data from an expected range to the range [0, 1].

Usage

normalize_minmax(r, mn = NULL, mx = NULL, clip = FALSE)

Arguments

r

numeric terra::SpatRaster or numeric vector. Input data.

mn

numeric vector of length one or NULL. Minimum expected value. If NULL (default), uses the minimum of r.

mx

numeric vector of length one or NULL. Maximum expected value. If NULL (default), uses the maximum of r.

clip

logical vector of length one. If TRUE, clip the output to [0, 1] after rescaling. If FALSE, values greater than mx are scaled proportionally to values above 1, and values less than mn to values below 0.

Value

Same properties as r, with values rescaled to the range [0, 1] if mn and mx match the range of r or extend beyond it. If clip = TRUE, values will be within [0, 1] even if this implies data loss.

Examples

normalize_minmax(read_caim())

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.