as_data_table: as_data_table

View source: R/as_data_table.R

as_data_tableR Documentation

as_data_table

Description

Convert raster object to data.table

Usage

as_data_table(x, na.rm = TRUE, return_df = TRUE, verbose = TRUE)

Arguments

x

RasterLayer.

na.rm

Logical if 'NA' should be removed.

return_df

If TRUE, 'data.frame' instead of 'data.table' is returned.

verbose

If TRUE, progress report is printed.

Details

Function to convert a RasterLayer into a data.table. For rasters that cannot be hold in memory, values are written blockwise.

Value

data.table

References

Adapted from Etienne B. Racine (https://gist.github.com/etiennebr/9515738)

Examples

ras <- raster::raster(nrow = 10, ncol = 10)
raster::values(ras) <- sample(x = c(1, 2, 3), size = 100, replace = TRUE)
as_data_table(x = ras)


mhesselbarth/UtilityFunctions documentation built on April 8, 2024, 9:38 a.m.