Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stretch

Stretch


Description

Linear stretch of values in a SpatRaster object. Provide the desired output range (minv and maxv) and the lower and upper bounds in the original data, either as quantiles (minq and maxq, or as cell values (smin and smax). If smin and smax are both not NA, minq and maxq are ignored.

Usage

## S4 method for signature 'SpatRaster'
stretch(x, minv=0, maxv=255, minq=0, maxq=1, smin=NA, smax=NA, filename="", ...)

Arguments

x

SpatRaster

minv

numeric >= 0 and smaller than maxv. lower bound of stretched value

maxv

numeric <= 255 and larger than maxv. upper bound of stretched value

minq

numeric >= 0 and smaller than maxq. lower quantile bound of original value. Ignored if smin is supplied

maxq

numeric <= 1 and larger than minq. upper quantile bound of original value. Ignored if smax is supplied

smin

numeric < smax. user supplied lower value for the layers, to be used instead of a quantile computed by the function itself

smax

numeric > smin. user supplied upper value for the layers, to be used instead of a quantile computed by the function itself

filename

character. Output filename

...

additional arguments for writing files as in writeRaster

Value

SpatRaster

Examples

r <- rast(nc=10, nr=10)
values(r) <- rep(1:25, 4)
rs <- stretch(r)
s <- c(r, r*2)
sr <- stretch(s)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.