Select to view content in your preferred language

Creating Many Shapefiles/Features using Python/Model Builder from one Shapefile.

6306
24
04-10-2012 12:35 PM
MarkFoster1
Deactivated User
We have a .shp with thousands of tracts each with specific number (i.e. tract 1, 2, 3....etc). Each tract has multiple contract numbers. (i.e. tract 1 = contract A, B, C...etc.) The contracts are in one field based on the tract number. Many of the contracts share tracts, but we want to see what each contract holds.

IS there a way to take the contracts and create them as individual shapefiles from the Tract shapefile. For example, we want to take contract A and all of the tracts associated with it to a shapefile.

We are new to python and any help would be helpful.

We are using Arc 10 and have version 2.6 of python

Thanks
Tags (2)
0 Kudos
24 Replies
SenthilnathanThyagarajan
Emerging Contributor
Wow, you have been of such great help.It works. I know too many questions I have asked  but I need to know is their a way if I can make the years as a parameter. So that this tool can become more generic in sense of input,output and the field(year) can be any field I want.
0 Kudos
T__WayneWhitley
Honored Contributor
So it works now?

I think what you are asking is how to make this a script tool.  A script tool accepts parameters you generally run from the Toolbox (or Catalog) and has the same gui interface appearance as other ArcGIS system tools.  Is this what you want, so that you can manually enter the years into a text box, several of them as what is called a multi-value input?  The script will operate the same way, just 'grabbing' the list input from what you input at your interface...instead of 'hard-coding' it in the script (as it is now).
0 Kudos
SenthilnathanThyagarajan
Emerging Contributor
Yes, I would like to make it more interactive. So I guess in the parameters I use feature class and for output I define the workspace. But how much changes would have to be done to the code and how to set the sql query.

Thank You.
0 Kudos
T__WayneWhitley
Honored Contributor
Not much change to the script, just have to set it to accept params from the toolbox script tool you create.

This pretty much explains it better than I can because there are some good pics, etc.:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00150000000n000000.htm

Anyway, the basic steps are:
1- From Catalog (or Toolbox), you can right-click and choose to create a custom toolbox.
2- Right-click the toolbox you created and select 'add script'...navigate to your script and select it, name how it is referenced, etc...
3- Create the params you need, following the help ref above....you need the 'multivalue' type to enter all your yr vals by.
4- oh, and of course, modify the script to take the input you just defined...

You can do it this way, for example, just for your multivalue param (if it is the 1st one you defined):

yrs = arcpy.GetParameterAsText(0)
yrs = yrs.split(';')

Hope that helps - and please don't forget to mark this post as answered!
0 Kudos
SenthilnathanThyagarajan
Emerging Contributor
You have been of great help Wayne. And sure I shall mark this as answered 🙂
0 Kudos