Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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')
share|improve this question
    
Ok I found out that this is a problem of the service pack (downloads2.esri.com/support/downloads/other_/…). I then tried to save it as an in_memory object without specifying any name as suggested in the link above and it worked, but then how could I make this files permanent? –  umbe1987 Sep 14 '12 at 17:51

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
    
Anyway, it doesn't work properly, it gives a strange result that has nothing to do with the result coming from a single application of the Zonal tool. Something doesn't work when looping... –  umbe1987 Sep 14 '12 at 19:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.