
rasterizeReduced(reduced, fullRaster, plotCol, mapcode = names(fullRaster),
...)
data.frame
or data.table
that has at least one
column of codes that are represented in the fullRaster
.RasterLayer
of codes used in reduced
that represents
a spatial representation of the datareduced
that
whose value will be plottedreduced
that
is represented in fullRaster
RasterLayer
of with same dimensions as fullRaster
representing
plotCol
spatially, according to the join between the mapcodeAll
contained within
reduced
and fullRaster
raster
library(data.table)
library(raster)
Ras <- raster(extent(0,15,0,15), res=1)
fullRas <- randomPolygons(Ras, numTypes=5, speedup=1, p=0.3)
names(fullRas) <- "mapcodeAll"
uniqueComms <- unique(fullRas)
reducedDT <- data.table(mapcodeAll=uniqueComms,
communities=sample(1:1000,length(uniqueComms)),
biomass=rnbinom(length(uniqueComms),mu=4000,0.4))
biomass <- rasterizeReduced(reducedDT, fullRas, "biomass")
# The default key is the layer name of the fullRas, so even
# if the reducedDT is miskeyed
setkey(reducedDT, biomass)
communities <- rasterizeReduced(reducedDT, fullRas, "communities")
setColors(communities) <- c("blue", "orange", "red")
Plot(biomass, communities, fullRas, new=TRUE)
Run the code above in your browser using DataLab