1

I want to merge two partly overlapping raster files which are obviously in the same CRS and have the same cell size, while taking the exact values of one of the input rasters in the overlapping areas, and hence overriding/replacing the values from the other raster in those areas, with QGIS. The problem is that both files have a cell offset of about half a pixel size laterally and vertically.

Raster 1: enter image description here

Raster 2 on top of raster 1: enter image description here

I tried several tools to merge both rasters (Merge, Mosaic Raster Layers, r.patch) but the output never adopted the exact values from one or even both of the input rasters. I also tried align the rasters with the Align Rasters tool as well as to remove the overlapping area from one of the rasters and then merge the two (now no longer overlapping) rasters, and some operations with the Raster Calculator, but without any success.

Is this kind of operation even possible with input files with an offset and if so, what would be the right way to execute it?

1 Answer 1

1

Assuming you want r2 to get the same extent as r1 and they have the same pixel size and CRS. One solution I found is this (QGIS 3.28.10):

  1. import your data
  2. create a point grid with the desired spatial resolution and set the extent (r1). Don't forget to set the extent and the horizontal and vertical spacing point grid parameters of the point grid
  3. sample the values of r2 using the point grid from step 2 sample raster values
  4. convert the sampled point from step 3 to raster by setting the appropriate parameters (cell size and extent mainly) convert point to raster convert point to raster
  5. export the converted raster from step 4 by using the extent from r1 export

In this way, you preserve the data type, the original pixel values and pixel size and your data will be overlaid perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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