Standard arithmetic operators for computations with SpatRaster objects and numeric values. The following operators and methods are available for SpatRaster:
Arith: +, -, *, /, ^, %%, %/%
Compare: ==, !=, >, <, <=, >=
Summary
: "max", "min", "range", "prod", "sum", "any", "all"
Math: "abs", "sign", "sqrt", "ceiling", "floor", "trunc", "cummax", "cummin", "cumprod", "cumsum", "log", "log10", "log2", "log1p", "acos", "acosh", "asin", "asinh", "atan", "atanh", "exp", "expm1", "cos", "cosh", "sin", "sinh", "tan", "tanh"
Math2: "round", "signif"
If multiple SpatRaster objects are used, these must have the same extent and resolution. Operators are applied on a cell by cell basis.
For SpatExtent the following methods have been implemented: "round", "floor", "ceil", "=="
SpatRaster
# NOT RUN {
r1 <- rast(ncols=10, nrows=10)
values(r1) <- runif(ncell(r1))
r2 <- rast(r1)
values(r2) <- 1:ncell(r2) / ncell(r2)
r3 <- r1 + r2
r2 <- r1 / 10
r3 <- r1 * (r2 - 1 / r2)
b <- c(r1, r2, r3)
b2 <- b * 10
s <- sqrt(b2)
round(s, 1)
# }
Run the code above in your browser using DataLab