Substitute(replace) cell values of a SpatRaster with a new value. See classify for more complex/flexible replacement.
methods
## S4 method for signature 'SpatRaster'subst(x, from, to, others=NULL, raw=FALSE, filename="",...)
Arguments
x: SpatRaster
from: numeric value(s). Normally a vector of the same length as to. If x has multiple layers, it can also be a matrix of numeric value(s) where nrow(x) == length(to). In that case the output has a single layer, with values based on the combination of the values of the input layers
to: numeric value(s). Normally a vector of the same length as from. If x has a single layer, it can also be a matrix of numeric value(s) where nrow(x) == length(from). In that case the output has multiple layers, one for each column in to
others: numeric. If not NULL all values that are not matched are set to this value. Otherwise they retain their original value.
raw: logical. If TRUE, the values in from and to are the raw cell values, not the categorical labels. Only relevant if is.factor(x)
filename: character. Output filename
...: Additional arguments for writing files as in writeRaster