Iterate Feature Selection equivalent in Python

1189
2
11-14-2012 11:03 AM
MargretAdaya
New Contributor
I made a tool in Model Builder that uses "Iterate Feature Selection" and I'm trying to figure out if there is an equivalent I can use in Python.

Basically, the tool goes through each feature in my "Subdivision_Copy" feature class and groups by the field "Community" and exports each feature as a shapefile in a "Scratch_Shapefiles" folder.

[ATTACH=CONFIG]19296[/ATTACH]

I'm still learning Python and I'm not too sure how to go about doing this.

Thanks for any help!
Tags (2)
0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor
I made a tool in Model Builder that uses "Iterate Feature Selection" and I'm trying to figure out if there is an equivalent I can use in Python.


Have you considered setting up your model as a script tool (with parameters), importing the toolbox using arcpy.ImportToolbox, and running the model from your Python script? If you're more comfortable with ModelBuilder - why not let it do the tricky stuff?

arcpy.ImportToolbox("Mytools.tbx","Model1")
arcpy.MyModel_mytools(input,output)


The code to do this in Python would be complicated enough (especially if you are using several group by fields) that this may be a good approach for you.

You could use the output of the Collect Values tool as an output parameter to pass the list of output datasets back to your python script.
0 Kudos
MargretAdaya
New Contributor
Thanks for your reply! I'll try it out!
0 Kudos