Skip to main content
added 59 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I used Alexandre Neto's script@AlexandreNeto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END

I used Alexandre Neto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END

I used @AlexandreNeto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END
Added language tag
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84

I used Alexandre Neto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END
# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END

I used Alexandre Neto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END

I used Alexandre Neto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END
Source Link

I used Alexandre Neto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":

# 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 arcpy

#Set Input Output variables
inputFile = u"D:\DXF-Export\my_shapefile.shp" #<-- CHANGE
outDir = u"D:\DXF-Export\\" #<-- CHANGE

# Reads My_shapefile for different values in the attribute
rows = arcpy.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 attribute_types:
    outSHP = outDir + each_attribute + u".shp"
    print outSHP
    arcpy.Select_analysis (inputFile, outSHP, "\"my_attribute\" = '" + each_attribute + "'")     #<-- CHANGE my_attribute to the name of your attribute

del rows, row, attribute_types

#END