I have two rasters: one that is a land cover map (cropland data layer) and the other is a rasterized polygon representing cranberry fields that aren't represented in the land cover raster that I have. I would like to replace the values of the land cover map with the value from the cranberry raster. The values of the land cover raster under the cranberry field raster are variable (from among 8 categories).

I assume the raster calculator is used for this, but I have little experience with that tool.

Image of the cranberry field raster: enter image description here

Image of the land cover raster with cranberry raster overlaying: enter image description here


OK - after some extensive googling and a fair bit of hair ripped out, I found a solution.

Instead of using a the raster calculator, I used a shape file for the marshes, and "rasterized" them. Instead of specifying a new .tiff, I wrote over the land cover raster that I wanted to update, and boom. Done. Not sure if that is the "correct" way, but it works for what I need.

  • Could you walk through these steps with a bit more detail? When I attempt to replicate this in QGIS 3.4, my resulting DEM is identical to my original. The rasterized data does not seem to write over the DEM.
    – BogBody
    Dec 11 '18 at 20:24
  • I can't seem to get my own protocol to reproduce. I did a bit of searching, though, and found this which may be helpful: gis.stackexchange.com/a/40480/85463 Dec 13 '18 at 20:09

The solution I found was to use the SAGA PATCHING algorithm. This tool takes a raster that has pixels you want to replace in another raster. All nodata pixels in the input raster will become the value of the target raster and all pixels with a value in the input raster keep their values. Essentially replacing the values in the target raster. (I'm using QGIS 3.10 but I believe this has been around for some time)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.