SpaDES (version 1.1.4)

rasterizeReduced: Convert reduced representation to full raster

Description

Convert reduced representation to full raster

Usage

rasterizeReduced(reduced, fullRaster, plotCol, mapcode = names(fullRaster),
  ...)

Arguments

reduced
data.frame or data.table that has at least one column of codes that are represented in the fullRaster.
fullRaster
RasterLayer of codes used in reduced that represents a spatial representation of the data
plotCol
a character, length 1, with the name of the column in reduced that whose value will be plotted
mapcode
a character, length 1, with the name of the column in reduced that is represented in fullRaster
...
Other arguments. None used yet.

Value

  • A RasterLayer of with same dimensions as fullRaster representing plotCol spatially, according to the join between the mapcodeAll contained within reduced and fullRaster

See Also

raster

Examples

Run this code
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 DataCamp Workspace