Using python I'm having problems when trying to attempt a FOR LOOP with the ZonalHistogram function of ArcGIS 10.1. It works fine if I use it only for one image but it gives me this error while for looping:
ExecuteError: ERROR 999999: Error executing function.
Create output table failed
Failed to execute (ZonalHistogram)
Here is my very simple script:
import arcpy
from arcpy.sa import *
arcpy.env.workspace = 'G:\\Chile_2012\\MODIS10A2.V005\\prova'
elev_ranges = 'G:\\Chile_2012\\MODIS10A2.V005\\DEM\\elev_ranges'
list = arcpy.ListRasters ()
out_dir = 'G:\\Chile_2012\\MODIS10A2.V005\\prova\\hypso\\'
arcpy.CheckOutExtension ('Spatial')
for raster in list:
ZonalHistogram (raster, 'Value', elev_ranges, out_dir+ raster+ '.dbf')
Best Answer
Solved.
The problem was assigning a name to the output table (as specified in the "SP5 announcement" of ESRI). I created "in_memory" files by appending an 'in_memory' string at the end of the pathname, and made a list on the temporary tables created in this way to merge them with the "Merge" tool. Tyhen I deleted all the temporary files by using the "arcpy.Delete_management ('in_memory')" tool and it worked fine. Hope this could help someone in the future. Here is the link with some bugs of ESRI. http://downloads2.esri.com/support/downloads/other_/185410.0_SP5_Announcement.pdf