View source: R/as_data_table.R
as_data_table | R Documentation |
Convert raster object to data.table
as_data_table(x, na.rm = TRUE, return_df = TRUE, verbose = TRUE)
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. |
Function to convert a RasterLayer into a data.table. For rasters that cannot be hold in memory, values are written blockwise.
data.table
Adapted from Etienne B. Racine (https://gist.github.com/etiennebr/9515738)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.