2

I have a DEM raster (let's call it R1) and another smaller and recent raster R2. I want to have R1 but replace the cell-values in locations where I have more recent DEM-data R2. Both R1 and R2 have values which range from 0 until to about 200. Can this be done in the Raster Calculator or I need to write a specific script for this?

1

You can do it in a two-step process using the raster calculator and the Grass r.patch algorithm- both from the processing toolbox.

First open the raster calculator from the processing toolbox. Use the expression "R2@1" and take the output extent from your larger 'R1' raster. This will result in an output raster with the same extent as your larger raster, which retains the cell values within the extent of the smaller DEM, and no-data values for the remaining areas.

enter image description here

You can then run the Grass algorithm r.patch, selecting the output from the previous raster calculation and the larger 'R1' DEM as the layers to patch together. This will create a new layer where the no-data values outside the smaller DEM extent are filled with the values from the larger 'R1' DEM.

enter image description here

If you need to automate this you could either create a processing model or call the algorithms from a short Python script.

1
  • 1
    thanks Ben, it worked!
    – user19277
    Feb 15 at 17:31

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.