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 a shapefile of a US. I need to make an individual shapefile for all the states in the US using a python in ArcGIS. How can I do it?

share|improve this question

marked as duplicate by whuber Apr 1 '14 at 19:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

For every state, or just one? – ianbroad Apr 1 '14 at 18:47
for every state – user28725 Apr 1 '14 at 18:54

I would loop through each feature in the FC and write the geometry to a new FC.

import arcpy

# This is a path to an ESRI FC of the USA
states = r'C:\Program Files (x86)\ArcGIS\Desktop10.2\TemplateData\TemplateData.gdb\USA\states'
out_path = r'C:\temp'

with arcpy.da.SearchCursor(states, ["STATE_NAME", "SHAPE@"]) as cursor:
    for row in cursor:
        out_name = str(row[0]) # Define the output shapefile name (e.g. "Hawaii")
        arcpy.FeatureClassToFeatureClass_conversion(row[1], out_path, out_name)
share|improve this answer

If you have a list of the states you can do something similar to the following:

import arcpy

statelist = [row.getValue('STATE_NAME') for row in arcpy.SearchCursor("INPUT DATASET")]

for state in statelist:
    arcpy.Select_analysis("INPUT DATASET", str(state), '[STATE_NAME] = "' + str(state) + '"')
share|improve this answer
Do i have to write the name of all the 52 states in the statelist ? – user28725 Apr 1 '14 at 18:53
You can use this: statelist = [row[0] for row in arcpy.da.SearchCursor(fc, ("NAME))] – ianbroad Apr 1 '14 at 19:01
For 10.0 you cannot use the 'da' option on the search cursor - so this will work: statelist = [row.getValue('STATE_NAME') for row in arcpy.SearchCursor("INPUT DATASET")] – dklassen Apr 1 '14 at 20:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.