freqDT: Speedy Raster Value Frequency Tabulation

freqDTR Documentation

Speedy Raster Value Frequency Tabulation

Description

A fast data.table-based alternative to raster::freq().

Usage

freqDT(x, ...)

## S4 method for signature 'RasterLayer'
freqDT(x, digits = 0, value = NULL, useNA = c("ifany", "no", "always"), ...)

## S4 method for signature 'RasterStackBrick'
freqDT(
  x,
  digits = 0,
  value = NULL,
  useNA = c("ifany", "no", "always"),
  merge = FALSE,
  ...
)

Arguments

x

A RasterLayer, RasterStack, or RasterBrick object field class.

...

Additional arguments as for raster::writeRaster(), on which this function relies.

digits

Integer for rounding the cell values. Argument is passed to round

value

A single numeric, logical, or NA value. If supplied, freqDT() will only count the number of cells with that value.

useNA

Character (one of "no", "ifany", or "always"). What to do with NA values? See table for details.

merge

Logical. If TRUE the list will be merged into a single data.table.

Author(s)

Joshua O'Brien

Examples

r <- raster(nrow = 18, ncol = 36)
r[] <- runif(ncell(r))
r[1:5] <- NA
r <- r * r * r * 5
freqDT(r)

freqDT(r, value = 2)

s <- stack(r, r*2, r*3)
freqDT(s, merge = TRUE)

rasterDT documentation built on Dec. 28, 2022, 1:57 a.m.