Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To combine mono-colored raster layers in R that have overlapping data using level plot, you can follow these steps:

  1. Load the necessary libraries:
library(raster)
library(lattice)
  1. Import the raster files:
r1 <- raster("raster1.tif")
r2 <- raster("raster2.tif")
  1. Use raster::merge to combine the rasters:
r_merged <- merge(r1, r2)
  1. Use levelplot() to plot the merged raster layers:
levelplot(r_merged)

The resulting plot will show the combination of the two original raster layers with overlapping data. To customize the color scheme, you can use the "col.regions" parameter in levelplot(). For example:

levelplot(r_merged, col.regions = rev(terrain.colors(255)))

This will use a color scheme from the "terrain.colors" function and reverse the order of the colors.