Thursday 14 September 2017

arcgis desktop - Iterating through columns in table using ModelBuilder?


I am unable to find any info on how to use ModelBuilder to run a certain spatial analysis function on each column in a table.


I have a table to sample locations and at each location there are a series of measures (e.g. temperature, flow rate, number of certain species). For each of those attributes (columns in the table), I was to run the IDW function from the surface tools.



This would be easy if I had each attribute in a separate shp/feature class, but not very efficient. I tried Iterate Feature Selection, but was unable to pass the field name as the Z value in the IDW function.


This is for ArcGIS 10.1 (Basic and Spatial Analyst license)



Answer



I believe you will need to build a small Python script and paste that into your Model. You would use the ArcPy module and build a field list on your layer:


fieldList = arcpy.ListFields("C:/Data/MyGIS.gdb/MyLayer")

and then you would iterate through the fieldList using a for loop, for example


for field in fieldList:
#run your spatial analysis function on field

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...