I need to sum all the cell values for a series of rasters and save instantly the result number.
I tried Zonal Statistics and Zonal Statistics as Table in arcpy so it returns a single value raster in the first and a table in the second case which takes many hours to run through all the rasters. I would like to ask if it is possible to create a code or use a different command that returns the sum of all the cells of a raster quicky.
The code has the following form:
from arcpy import env
from arcpy.sa import *
arcpy.env.workspace = "C:/MSc_thesis/run500"
plist = arcpy.ListRasters("p*", "GRID")
for i in plist:
inZoneData = 'Karitaina_watershed_polygon'
zoneField = "Value"
inras = Raster(i)
outZon = ZonalStatistics(inZoneData, zoneField, inras,"SUM")
outZon.save(os.path.join(arcpy.env.workspace,"s" + str(i)))
Please format your code correctly.
How many rasters are being iterated? One thing which will improve performance is to supply the inzone feature as a raster, otherwise it is converted from feature to raster for each iteration, although this will unlikely be a huge gain.