gp/arcpy scratch name methods can be very slow when the workspace in which you are generating scratchnames gets full of many files
#create scratch workspace name tempDIR = "F:\\Data\\Reg09" tempWorkspacePrefix = "update" tempWorkspaceSuffix = 0 count = 0; for raster in rasterList: if count%30 == 0: # this is modulus operator, so should be true the first iteration and every 30 iterations thereafter. tempWorkspaceSuffix = tempWorkspaceSuffix + 1 tempWS = tempWorkspacePrefix + str(tempWorkspaceSuffix) if not arcpy.Exists(tempDIR + os.sep + tempWS): arcpy.CreateFolder_management(tempDIR, tempWS) out = tempDIR + os.sep + tempWS + os.sep name = os.path.basename(raster).strip(".tif") # removes .tif from the file name arcpy.env.cellSize = "MINOF" arcpy.gp.ZonalStatisticsAsTable_sa(region, "VALUE", raster, out+name+".dbf","DATA", "ALL") print" Raster " + str(raster) + " processing completed at " + time.asctime( time.localtime(time.time()) ). count = count + 1
My python code is below....any suggestions on how to modify this code?
I should add that sometimes this script runs and sometimes not.
import gc gc.enable()
os.path.basename(os.path.splitext(path)[0])
File "F:\Data\Reg09\attributetifsReg09.py", line 56, in <module> arcpy.gp.ZonalStatisticsAsTable_sa(region, "VALUE", raster, out+name+".dbf","DATA", "ALL") <class 'arcgisscripting.ExecuteError'>: ERROR 999999: Error executing function. Workspace or data source is read only. Workspace or data source is read only. [The F:\Data\Reg09\update1\ workspace is read only.] ERROR 010067: Error in executing grid expression. Zonal statistics program failed Failed to execute (ZonalStatisticsAsTable). ERROR 999999: Error executing function. Workspace or data source is read only. Workspace or data source is read only. [The F:\Data\Reg09\update1\ workspace is read only.] ERROR 010067: Error in executing grid expression. Zonal statistics program failed Failed to execute (ZonalStatisticsAsTable).
[The F:\Data\Reg09\update1\ workspace is read only.]
ERROR 010067: Error in executing grid expression.
Failed to execute (ZonalStatisticsAsTable).
if count%30 == 0: # this is modulus operator, so should be true the first iteration and every 30 iterations thereafter.
We recently published a toolbox (first prize at the ESRI UC 2011 AppFair!) that includes tools that do overlap processing for statistics and area tabulations, among other things.
USGS Open-File Report 2010�??1268
National Water-Quality Assessment (NAWQA) Area-Characterization Toolbox
By Curtis V. Price, Naomi Nakagaki, and Kerie J. Hitt
http://pubs.usgs.gov/of/2010/1268/
The published version has only limited support for 10.x, but I have an updated version that will be posted there soon. If you are interested, let me know and I can send it your way.
> I am interested in checking out the tool for use with 10. Is it available on the web?
A version of the NAWQA toolbox that runs under 10.x is available in ArcGIS Online here:
http://www.arcgis.com/home/item.html?id=cbb59504f59f4e18b23817fb0ef40e56
Is there a link to an updated tool that we could download?