I'm trying to merge one band rasters into one multiband raster using gdalogr:merge in python. The fact is that I get an artefact, a lots of my values are converted near 0, which does not appear when I'm doing it manually from QGIS GUI (Raster-> Merge).

This is the histogram I get with the script enter image description here

and this one manually... enter image description here

my syntax in python :

outputs_GDALOGRMERGE_1=processing.runalg('gdalogr:merge', {"INPUT" :[blue,green,red,rededge,nir], "PCT" : False, "SEPARATE": True,"NODATA":0, "OUTPUT":"output_path"})

I tried using the algorithm a more classical way with

outputs_GDALOGRMERGE_1=processing.runalg('gdalogr:merge', [blue,green,red,rededge,nir],False,True,0,5,None)

But the same issue was happening and I thought maybe it came from the Float32 conversion, apparently not...


Float32 conversion is used by default with gdalogr:merge (manually from QGIS GUI) so, I don't think that issue can come from this. However, when I print 'Processing Information' for 'gdalogr:merge' tool:

enter image description here

it can be observed that you apparently have an inexistent parameter ("NODATA":0) in first command and a wrong number of them in second one. I don't know why it produced a result but it could be origin of problem.

Try out following command:

outputs_GDALOGRMERGE_1=processing.runalg('gdalogr:merge', {"INPUT" :[blue,green,red,rededge,nir], "PCT" : False, "SEPARATE": True,"RTYPE":5, "OUTPUT":"output_path"})


outputs_GDALOGRMERGE_1=processing.runalg('gdalogr:merge', {"INPUT" :[blue,green,red,rededge,nir], "PCT" : True, "SEPARATE": True,"RTYPE":5, "OUTPUT":"output_path"})

I hope that it helps.

  • Hey ! Thanks for the answer but unfortunately not :/ The nodata parameter comes from the fact that documentations are different depending on where you search... The batch doc of gdal merge here gdal.org/gdal_merge.html contains a lot more parameters that are not available in the algorithm doc here docs.qgis.org/2.6/en/docs/user_manual/processing_algs/gdalogr/… ... – Clement Nov 6 '17 at 15:07
  • First one is not for processing tool (it is for running in console). Second one is exactly as in my answer. You shouldn't mix arbitrarily documentation. If you want to use gdal_merge.py in your code, instead processing, syntax is completely different. – xunilk Nov 6 '17 at 15:18

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.