dt2raster | R Documentation |
data.table
to a RasterLayer
for plotting, etc.Convert data.table
to a RasterLayer
for plotting, etc.
dt2raster(dt, r, val)
dt |
|
r |
|
val |
The name of the column in |
A RasterLayer
object.
Alex Chubaty
library(data.table)
library(sp)
library(raster)
r <- raster(nrows = 10, ncols = 10)
r[] <- 10
# using x,y coordinates
#dt1 <- data.table(X = , Y = , value = r[])
# using pixel ids
dt2 <- data.table(ID = 1L:ncell(r), VALUE = r[])
dt2[, VALUE := sample(1L:10L, ncell(r), replace = TRUE)]
if (interactive())
plot(dt2raster(dt2, r, "VALUE"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.