Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a feature class with over 2,000 features, and I need to make them all individual feature classes based on a field.

I know there has to be a way to do this, but I just can't figure it out!

Any takers?

share|improve this question
    
What do you mean when you say "Split by Attribute"? Do you want the attribute value used to select features out into a new feature class with all features sharing the same value? Or do you want the attribute value used to name the output feature class while it's geometry is used to clip? A diagram or link to a page would help make this clear so can you edit your Question, please? –  PolyGeo Mar 16 at 19:38
1  
The SplitLayerByAttributes tool was updated and can be found here resources.arcgis.com/gallery/file/geoprocessing/… –  Dan Patterson Mar 17 at 1:51
    
Has anyone used the model shown above? I am having an issue with it. I can see that it almost works, but it only saves the last feature that is selects when iterating. Thanks –  David Ainley Sep 18 at 17:33

9 Answers 9

up vote 12 down vote accepted

You could use the Split Layer by Attribute tool.

There are versions available for:

share|improve this answer
    
Thanks, but I couldn't find that tool. I found "Select Layer By Attribute" that could work if I was better at coding and could write a loop...sigh –  Sophie May 19 '11 at 22:40
1  
@Sophie, both 9x and 10x links are provided in my answer. –  artwork21 May 19 '11 at 22:43
    
artwork21 is correct, the links are in his answer (the author) –  Dan Patterson May 19 '11 at 22:55
    
Oh gosh! I feel sheepish! Thanks a TON! It worked like a charm. :) –  Sophie May 20 '11 at 1:40
2  
note to self be sure to upvote and select the answer that works. –  Brad Nesom May 20 '11 at 2:16

Did you see Split Layer By Attributes tool updated for ArcMap 10 here? If it does not work you can use Split (Analysis) for your needs.

Splitting the Input Features creates a subset of multiple output feature classes. The Split Field's unique values form the names of the output feature classes. These are saved in the target workspace.

split

Example Code:

import arcpy
arcpy.env.workspace = "c:/data"
arcpy.Split_analysis("Habitat_Analysis.gdb/vegtype", "climate.shp", "Zone",
                     "C:/output/Output.gdb", "1 Meters")

I hope it helps you...

share|improve this answer
    
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split. –  ccn Jan 31 '13 at 16:25
    
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer. –  PolyGeo Dec 3 at 6:39

I do not have access to ArcMap 10, only 9.3, but I expect that it won't be very different from this.

You can create a simple script in Python, that checks your attribute field for different values, and then, for each of them runs a SELECT operation to your original Shapefile.

If you are not familiar with python scripting, all you need to do is open you IDLE (the python GUI) create a new file, and copy the code below. After adapting the code for your my_shapefile, outputdir and my_attribute it should work.

# Script created to separate one shapefile in multiple ones by one specific
# attribute

# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcgisscripting

# Starts Geoprocessing
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1

#Set Input Output variables
inputFile = u"C:\\GISTemp\\My_Shapefile.shp" #<-- CHANGE
outDir = u"C:\\GISTemp\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = gp.searchcursor(inputFile)
row = rows.next()
attribute_types = set([])

while row:
    attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
    row = rows.next()

# Output a Shapefile for each different attribute
for each_attribute in atribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    gp.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types, gp

#END
share|improve this answer

Here are some more free third-party tools that split by attribute:

share|improve this answer
    
+1 For recommending GME –  Aaron Jan 31 '13 at 16:38

You can achieve this with a very simple model if you have ArcGIS 10.0 or higher.

Create a model with Feature Iterator where the group by field is the attribute you wish to select by then send the output to the copy features tool using inline substitution to ensure a unique file name. The model is shown below:

Model for extracting by attribute

share|improve this answer

You can use a Search Cursor to loop through individual features in a feature class and write the geometries to unique feature classes. In this example, I use a feature class of the USA and export the states to new shapefiles:

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

This is an even easier way to do this... and it outputs into a GDB.

http://www.umesc.usgs.gov/management/dss/split_by_attribute_tool.html

download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.

share|improve this answer

I know you can use an iterator in model builder, but if you prefer to use python here is something I came up with. Add the script to a toolbox with the parameters in order as Input shpfile, fields(multivalue,obtained from input), and workspace. This script will split the shapefile into multiple shapefiles based on the fields you select, and output them into a folder of your choice. Hope this helps. (This is the first time I've posted a script. Please vote up if it helps you at all. Thanks a ton.)

import arcpy, re

arcpy.env.overwriteOutput = True

Input = arcpy.GetParameterAsText(0)  
Flds = "%s" % (arcpy.GetParameterAsText(1)) 
OutWorkspace = arcpy.GetParameterAsText(2) 


myre = re.compile(";")
FldsSplit = myre.split(Flds)

sort = "%s A" % (FldsSplit[0])
rows = arcpy.SearchCursor(Input, "", "", Flds, sort)

for row in rows:
    var = []
    for r in range(len(FldsSplit)):
        var.append(row.getValue(FldsSplit[r]))
    Query = ''
    Name = ''
    for x in range(len(var)):
        if x == 0:
            fildz = FldsSplit[x]
            Name = var[x] + "_"
            Query += (""" "%s" = '%s'""" % (fildz, var[x]))
        if x > 0:
            fildz = FldsSplit[x]
            Name += var[x] + "_"
            Query += (""" AND "%s" = '%s' """ % (fildz, var[x]))
    OutputShp = OutWorkspace + r"\%s.shp" % (Name)
    arcpy.Select_analysis(Input, OutputShp, Query)
share|improve this answer

If you want learn how to author your own Split By Attribute tool using ArcPy the steps are demonstrated in an eLearning video at Discover Spatial:

Disclaimer: I am the author and presenter of the above online training course

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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