Python Script for making changes to large number of files

3352
4
Jump to solution
11-19-2015 07:56 AM
TaraPrince1
New Contributor II

Hello!

I have been tasked with taking a large number of shapefiles (over 10,000) that have no coordinate system and adding one so that they can be used in ArcMap and then convert them to polygons as they are currently polylines.  I can write small python scripts but I have never taken on something of this magnitude before.  Can anyone direct me to a place where I can find sample scripts to look at?  I'll never learn if I just ask someone else to do it for me.

Thanks

Tara

0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

Tara, you can also do this with ModelBuilder fairly easily. It's ideal for once-off tasks like this, even if you know Python. (In fact a little bit of Python skill makes Model Builder much more powerful!)

The approach I use is I build a model and test it for one dataset, once that is working, I add an iterator to the model and go home while it runs.

View solution in original post

4 Replies
LukeSturtevant
Occasional Contributor III

You could use either arcpy walk ​ or os.walk to cycle through different workspaces. If all the shapefiles are in one workspace you could just set your environment workspace and iterate through a list of features. For each feature in the list define projection​ and then you could run feature to polygon .

Each link above has example codes if you scroll to the bottom of the page as well as proper syntax and parameter input types. Let us know if you need help setting up the basic code structure.

curtvprice
MVP Esteemed Contributor

Tara, you can also do this with ModelBuilder fairly easily. It's ideal for once-off tasks like this, even if you know Python. (In fact a little bit of Python skill makes Model Builder much more powerful!)

The approach I use is I build a model and test it for one dataset, once that is working, I add an iterator to the model and go home while it runs.

TaraPrince1
New Contributor II

I did end up using model builder.  Just in case anyone else could use it I inserted an iterator for Feature Class and then used the Define Projection tool under Data Management Tools > Projections and Transformations > Define Projection. 

0 Kudos
MitchHolley1
MVP Regular Contributor

Something like:

Idk... just an idea to explore.

0 Kudos