Scale a SpatRaster
object (from the terra
R package in) values to a range
between 0 and 1.
Note
This function takes a SpatRaster object as input, calculates its
minimum and maximum values, and scales all its values to a range between 0
and 1. This is useful for normalization purposes in spatial analysis and
modeling. The function relies on the terra
package for spatial data
manipulation.
Examples
library(terra)
r <- rast(ncols = 10, nrows = 10)
values(r) <- seq_len(terra::ncell(r))
Scale_0_1(r)
#> class : SpatRaster
#> dimensions : 10, 10, 1 (nrow, ncol, nlyr)
#> resolution : 36, 18 (x, y)
#> extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84)
#> source(s) : memory
#> name : lyr.1
#> min value : 0
#> max value : 1