There are two rasters A and B. A is smaller but within B and since A has more up-to-date pixel values, I was able to merge A and B with "Mosaic raster layers" tool in QGIS which replaces B pixel values with A. However there is a problem, that A does have no value pixels (which are dummy high numbers e.g. -3.40282e+038), when the merge happens it overwrites the values of B with high noData values which I don't want it to happen as B has values for those missing points within A. Is there any way it could be done in QGIS? It should be possible with gdal_calc.py, but I don't know how to set up the rules.

I have tried the following so far, but i hope there is a one-step way of doing it:

  1. Clipped larger B to the extent of A (otherwise gdal_calc.py doesn't work for different dimensions)
  2. gdal_calc.py -A A.tif --NoDataValue=-3.40282e+038 -B B.tif --outfile=result.tif --calc="where(A==-3.40282e+038,B,A)"

After doing these steps i was planning to do mosaic of result.tif and B.tif, however result.tif is not correct, so I must be doing the where rule in gdal_calc.py incorrectly.

Rather than doing a lot of steps, there might be one tool which specifies "do not merge NoData of A" etc, but at the moment the merge product is coming back with -3.40282e+038, whereas original A raster didn't show up this value in symbology.

Your Answer

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

Browse other questions tagged or ask your own question.