subsDT {rasterDT} | R Documentation |
Speedy Raster Value Substitution
Description
A fast data.table
-based alternative to
raster::subs()
.
Usage
subsDT(x, dict, by = 1, which = 2, subsWithNA = TRUE, filename = "", ...)
Arguments
x |
Categorical |
dict |
A |
by |
Vector of one or possibly more integers or character
strings giving the indices or names of the column in
|
which |
Vector of one or possibly more integers or character
strings giving the indices or names of the column in
|
subsWithNA |
Logical. If |
filename |
Character string giving (optional) file name to which the resultant raster should be written. |
... |
Additional arguments as for
|
Value
A RasterLayer
object.
Author(s)
Joshua O'Brien
Examples
r <- raster(ncol = 10, nrow = 10)
r[] <- round(runif(ncell(r)) * 10)
df <- data.frame(id = 2:8, v = c(10, 10, 11, 11, 12:14))
x <- subsDT(r, df)
x2 <- subsDT(r, df, subsWithNA = FALSE)
df$v2 <- df$v * 10
x3 <- subsDT(r, df, which = 2:3)
s <- stack(r, r*3)
names(s) <- c("first", "second")
x4 <- subsDT(s, df)
x5 <- subsDT(s, df, which = 2:3)