crosstabDT {rasterDT} | R Documentation |
Speedy Raster Cross-tabulation
Description
A fast data.table
-based alternative to
raster::crosstab()
.
Usage
crosstabDT(x, y, digits = 0, long = FALSE, useNA = FALSE)
Arguments
x |
A |
y |
If |
digits |
Integer. The number of digits for rounding the
values before cross-tabulation. Default is |
long |
Logical. If |
useNA |
Logical. Should the returned table or
|
Value
Either a table or a data.table
recording the
frequency of each combination of raster values.
Author(s)
Joshua O'Brien
Examples
r <- raster(nc = 5, nr = 5)
r[] <- runif(ncell(r)) * 2
s <- setValues(r, runif(ncell(r)) * 3)
crosstabDT(r, s)
rs <- r/s
r[1:5] <- NA
s[20:25] <- NA
x <- stack(r, s, rs)
crosstabDT(x, useNA = TRUE, long = TRUE)
[Package rasterDT version 0.3.2 Index]