AnsweredAssumed Answered

Model Builder/Python: batch raster calculation

Question asked by tomachu on Mar 28, 2016
Latest reply on Mar 28, 2016 by curtvprice

I wish to carry out a raster calculation on a batch of rasters.
I want to add rasters by month, as identified by their file name.


I.e. all rasters within the month of January should add together and output a single jan.png/raster file. Then all the rasters within Feb should add together and produce a single FEB.png.


Rather than manually write a new rast calc expression for each month, I would prefer to automate it via either python or modelbuilder.


My plan outline is as follows:


Input Files. 36 Weekly raster files







Raster operation.

(raster1+raster2+raster3+raster4)/(raster1+raster2+raster3+raster4) = month.png


output. 12 rasters for each month.





is it possible to write a python expression or create a modelbuilder which will add rasters by month using their filename?

Current Attempts


I have built a model, however this only runs on the rasters I provide it, requiring me to write a new expression each time. In other words it's the same as manually running raster calculator and writing a new expression for each month, I wish to automate this via modelbuilder.