2

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

1 Answer 1

2

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"
1
  • 3
    This is a bit of an old question, but is there a way to pass a list of a large number of tiff files to gdal_calc.py and sum them all?
    – qdread
    Commented Nov 3, 2020 at 17:43

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.