I need to create a single tiff files from several others (each have the same extent and resolution) and the output file need to have a single band containing the aggregated/sum of the values in the separate files.

I was playing with gdal_merg, - in the the gdal_merge documentation the definition include "In areas of overlap, the last image will be copied over earlier ones." wich is not what I need. I got somewhat over that by using the -separate parameter that give me a single file with multiple bands, each representing one of the source files.

Is there a python/command line way how I can sum these multiple bands programmatically? (similar to the Raster Calculator GUI in QGIS)

Or even better do it in a single step?

Thanks in advance. g


You can do in a single step with gdal_calc.py. For instance:

# example 1 - add two files together
gdal_calc.py -A input1.tif -B input2.tif --outfile=result.tif --calc="A+B"
| improve this answer | |

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.