0

I have 130 rasters in a folder and I would like to create a new raster containing the sum of the 130 raster cell values. How can I do this?

0

You can us gdal_calc.py in a for loop. First read all the files name, then use:

gdal_calc.py -A input1.tif -B input2.tif --outfile=result.tif --calc="A+B"

And then in a loop:

gdal_calc.py -A inputX.tif -B result.tif --outfile=result.tif --calc="A+B"

Where inputX.tifis the current file you are looping over, so your loop should start at input3 since the first two have already been summed to create result.tif.

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.