3

In a folder I have 360 precipitation raster files and I want to sum them all to the raster calculator

2
  • 1
    Hi Juan, do you have any ability with python? Jul 16, 2014 at 23:23
  • 1
    Would you be able to edit your question to indicate the version of ArcGIS for Desktop that you are using and what you have tried so far with respect to tryi9ng to do this with the raster calculator, please?
    – PolyGeo
    Jul 16, 2014 at 23:30

3 Answers 3

2

You can perform these calculation on a per cell basis using Cell Statistics (Spatial Analyst). Specify the "SUM" statistic type.

enter image description here

2
  • Hi @aaron, that is true, but what I think is the problem is that he wants to do 360 of them and that would be tedious to put into the tool... perhaps. It would take less time to do it manually (once) than to write a script to list the rasters and feed that into a tool but if you want to do it a few times it would be worth scripting. Jul 16, 2014 at 23:49
  • 1
    It may be more tedious to write a script to do the work. Adding the rasters is a couple clicks of a mouse.
    – Aaron
    Aug 27, 2016 at 5:32
2

There's a good solution in one of the answers on this page: https://geonet.esri.com/thread/25945

arcpy.env.overwriteOutput = 1  
arcpy.CheckOutExtension('Spatial')  
arcpy.env.scratchWorkspace = outPath  
arcpy.env.workspace = dataPath  
#create a list of rasters in the workspace  
rasters = arcpy.ListRasters('','')  

i = 0  
#loop through rasters in list  
for raster in rasters:  
    print "processing raster: %s" %os.path.join(dataPath,raster)  

    #convert nodata to zero  
    out1 = Con(IsNull(raster), 0, raster)  

    #sum rasters together  
    if i == 0:  
        out2 = arcpy.Raster(out1)  
        i += 1  
    else:  
        out2 = out2 + out1  
        i += 1  

#save final output  
out.save(os.path.join(outPath,'sumRas'))
0

The code above is incorrect. See this edit to avoid an 'expected raster or raster layer' error.

 if i == 0:  
        out2 = out1  
        i += 1  
    else:  
        out2 = out2 + out1  

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.