AnsweredAssumed Answered

Error when using iteration in Zonal table as Statistics

Question asked by bcelik_83 on Jun 14, 2015
Latest reply on Jun 15, 2015 by bcelik_83

I am pretty new in ArcGIS, however I was able to create my script accept the last step.

I am using night lights to get my data. I light data for several years, i want to get my data for each year. I was able to generate iterations and it is working accept last step.

Here is my code:


# Import arcpy module
import arcpy
from arcpy import env
from import *

arcpy.env.workspace = r"D:\Research-NightLights\yeni"
# Check out any necessary licenses

# Local variables:
Tur_pro_09 = "D:\\Turkey09\\admin\\Turpro09.shp"
Tur_lyr = "D:\\Turkey09\\admin\\Turkey"

Tur_dist_09 = "D:\\Turkey2009\\admin\\Turdist09.shp"

arcpy.MakeFeatureLayer_management(Tur_pro_09, Turkey_lyr)
print "makefeature"

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(Tur_lyr, "NEW_SELECTION", "\"ID\" = '01'")
print "attribute"

rasterList = arcpy.ListRasters("f*")
for raster in rasterList:
    print "list"

# Process: Clip (1)
    arcpy.Clip_management(raster, "25.665181 35.812875 44.826408 42.104629", "y1"+str(raster[1:]), Tur_lyr, "255", "ClippingGeometry", "NO_MAINTAIN_EXTENT")
print "clip1"

rasterList1 = arcpy.ListRasters("y1*")
for raster in rasterList1:
    print "list (2)"
# Process: Raster to Polygon
    arcpy.RasterToPolygon_conversion(raster,"y2"+str(raster[1:]), "NO_SIMPLIFY", "Value")
print "polygon"

fcs = arcpy.ListFeatureClasses("y2*", "polygon")
for raster in fcs:
    print "poly_clip"
# Process: Clip (2)
arcpy.Clip_analysis(Tur_dist_09, raster, "y3"+str(raster[1:]), "")
print "clip2"

rasterList3 = arcpy.ListRasters("y1*")
for raster in rasterList3:
    print "list (3)"

# Process: Zonal Statistics as Table, "Name", raster,"j"+str(raster[5:])+".dbf", "DATA", "MEAN")
    print "Got zonal stats for "


Here is the Error I get: (it works perfect until Zonal Statistics as Table step)


Traceback (most recent call last):
  File "C:/Users/Bilalce/Desktop/fully", line 64, in <module>, "Name", raster,"j"+str(raster[5:])+".dbf", "DATA", "MEAN")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\", line 498, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
Create output table failed
Failed to execute (ZonalStatisticsAsTable).


(Curtis Price added formatting)