subst | R Documentation |
Substitute(replace) cell values of a SpatRaster with a new value. See classify
for more complex/flexible replacement.
## S4 method for signature 'SpatRaster'
subst(x, from, to, others=NULL, raw=FALSE, filename="", ...)
x |
SpatRaster |
from |
numeric value(s). Normally a vector of the same length as 'to'. If |
to |
numeric value(s). Normally a vector of the same length as 'from'. If |
others |
numeric. If not |
raw |
logical. If |
filename |
character. Output filename |
... |
Additional arguments for writing files as in |
SpatRaster
classify
r <- rast(ncols=5, nrows=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)
# multiple output layers
z <- subst(r, 2:3, cbind(20,30))
# multiple input layers
rr <- c(r, r+1, r+2)
m <- rbind(c(1:3), c(3:5))
zz <- subst(rr, m, c(100, 200))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.