Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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, "ID", Standard_Average_Annual_Rainfall_SAAR, table_i_, "DATA", "ALL")

share|improve this question
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 posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.