2

I have created a model to iterate a folder of 5 shapefiles to apply the Zonal Stats as Table tool to a raster. My output table is saved as table%i% so i'm expecting it produce 5 tables (table0, table1, table2, table3, table4, table5). However it keeps saving over the same table so I just get 'table0'. Can anyone suggest where i'm going wrong? Thanks.

--

Import arcpy module

import arcpy

Check out any necessary licenses

arcpy.CheckOutExtension("spatial")

Load required toolboxes

arcpy.ImportToolbox("Model Functions")

Script arguments

v5_River_Shapefiles = arcpy.GetParameterAsText(0) if v5_River_Shapefiles == '#' or not v5_River_Shapefiles: v5_River_Shapefiles = "M:\Dissertation\Data\5 River Shapefiles" # provide a default value if unspecified

Local variables:

FeatureClass = v5_River_Shapefiles table_i_ = FeatureClass Name = v5_River_Shapefiles Standard_Average_Annual_Rainfall_SAAR = "SAAR 5km (F)\Standard Average Annual Rainfall (SAAR)"

Process: Iterate Feature Classes

arcpy.IterateFeatureClasses_mb(v5_River_Shapefiles, "", "POLYGON", "RECURSIVE")

Process: Zonal Statistics as Table

arcpy.gp.ZonalStatisticsAsTable_sa(FeatureClass, "ID", Standard_Average_Annual_Rainfall_SAAR, table_i_, "DATA", "ALL")

  • 2
    Without looking at the code behind the model, it's difficult to pinpoint a particular problem, though your iterator is likely not being incremented after each run. Why don't you export (Model->Export->To Python Script) the model and post the code? – Paul Jun 20 '13 at 19:13
  • Hi Paul, Good suggestion. Please find the code above. Many thanks – Baz Jun 21 '13 at 10:10
  • OK I have cracked it. I need to change the output table to table%name% – Baz Jun 21 '13 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.