I posted this to spatial analyst but thought it might be more appropriate here.I have reclassified many raster to be only 0's and 1's and I would like to sum the 1's together and output a new raster which is basically a count of those rasters.I have used the code from a thread in spatial analyst so I am open to different tools to do this processing. When I run the code I do receive an output but it is wrong and python keeps crashing each time I try to run it so I don't receive an error message. Can someone please tell me what I am doing wrong.Thanks
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
import os
# Set environment settings
arcpy.env.workspace = "D:/sumrasters/rasterimgs"
outputfolder="D:/sumrasters/output_sumRaster"
datapath="D:/reclass/sumrasters/rasterimgs"
arcpy.env.overwriteOutput = 1
arcpy.CheckOutExtension('Spatial')
arcpy.env.scratchWorkspace = r"c:\temp\scratch.gdb"
#create a list of rasters in the workspace
rasters = arcpy.ListRasters("*","IMG")
i = 0
#loop through rasters in list
for raster in rasters:
print rasters
#sum rasters together
if i == 0:
outSUM = arcpy.Raster(raster)
i += 1
else:
outSUM = outSUM + raster
i += 0
#save final output to the current workspace
outSUM.save(os.path.join(outputfolder,"sumRas.img"))
print "end of processing"