1

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?

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Sep 15, 2019 at 15:52

1 Answer 1

3

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.

answered Sep 16, 2019 at 12:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.