I am trying to combine two rasters into one, so that I can better work on it as one topography layer. I need both, because the first (1) one has complete information on my focus area, while the second (2) one carries information on the environment.

Put in another way, raster n°2 has a bigger extent, but it is very imprecise in my focus area. I tried two different things:

  1. clipping raster n°2 by a mask layer, so to have a "hole" where I can then merge raster n°1, but this is not working. The clipped raster n°2 has values that I do not understand and is not visible.
  2. directly using raster calculator to merge the two topographies (intuitively I thought this is not the right way, but still...). This also did not work.

enter image description here enter image description here enter image description here

2 Answers 2


The extent of your two rasters is different. That makes it a bit tricky and you have to create an intermediate raster, based on the (precise) values of the focus area, but with the larger extent of the other raster. Like this, however, you will get NoData cells. These are not so easy to handle with Raster calculator. So you first have to fill the NoData pixels with "neutral" values to then be able to use Raster calculator.

Proceed like this:

  1. Common CRS: Make sure both rasters have the same CRS. If not, reproject - probably best to reproject (warp) the larger, imprecise, raster to the CRS of the smaller raster.

  2. Raster with whole extent: Create a new, constant raster layer with the same CRS, and extent as the larger raster layer and the constant value of 1. Make sure the resolution is the same as the more precise raster layer (focus area).

  3. Get precise cell values for whole extent: Use Raster Calculator and multiply the small, precise, raster and the raster created in step 2. Like this, muliplying with 1, you get the same values as the input layer (precise values for your focus area) and with NoData values outside the focus area but within the extent of the large, imprecise, raster layer. Be sure to write the output layer to the disk and don't create a on-the-fly raster as QGIS doesn't properly create NoData values otherwise.

  4. Fill NoDate values: Use Fill NoData Cells on the raster created in step 3. Use 0 as Fill value. Like this, you have the initial, precise values in the focus area and 0 outside of it.

  5. Combine values of both rasters: Now again use Raster Calculator, this time adding the layer from step 4 to the larger one of the initial layers (those with imprecise values for areas outside the focus area). Use an if condition like this: if (raster_step4@1 > 0, raster_step4@1, raster_large@1) to get the precise values for the focus area and the imprecise values for the rest of the extent.


This is what now Merge does in QGIS 3.34

  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 17 at 20:39

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.