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

subst

replace cell values


Description

Substitute(replace) cell values of a SpatRaster with a new value. See classify for more complex/flexible replacement.

Usage

## S4 method for signature 'SpatRaster'
subst(x, from, to, filename="", ...)

Arguments

x

SpatRaster

from

numeric value(s)

to

a single numeric value

filename

character. Output filename

...

Additional arguments for writing files as in writeRaster

Value

SpatRaster

See Also

Examples

r <- rast(ncol=5, nrow=5, xmin=0, xmax=1, ymin=0, ymax=1, crs="")
r <- init(r, 1:6)
x <- subst(r, 3, 7)
x <- subst(r, 2:3, NA)
x <- subst(x, NA, 10)

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.