1

1) I have a polygon shapefile with 1000 multi-part polygons in it. Each Row of the table is a multipart polygon.

2) I need 1000 shapefiles with 1 multi-part polygon in each.

3) Each output shapefile with 1 multi-part polygon needs to be named with a name from the attribute table (1) unique to each input polygon.

Open to ArcGIS, ArcPy, Model Builder, OGR, QGIS solutions.

  • 1
    If you have a multipart polygon with 1000 parts, then overall you have one row in your attribute table. If I understand it correctly, you need to address a value from one record of this row to all of your polygons. Is my theory correct? – Gabor Farkas Sep 23 '14 at 18:28
  • ill clear up the question wording, it is confusing, thanks. – If you do not know- just GIS Sep 23 '14 at 18:29
  • 1
    Also related: http://gis.stackexchange.com/questions/97995/generate-massive-shapefiles/97999#97999 and http://gis.stackexchange.com/questions/9998/exporting-feature-class-into-multiple-feature-classes-based-on-field/9999#9999 – Chris W Sep 24 '14 at 00:15
  • Thanks Chris W, the split by layer tool is one I always forget about. – If you do not know- just GIS Sep 24 '14 at 00:51

3 Answers3

2
# import libraries
import arcpy, os

# path to file
polyFC = r'C:\junk\raa\RAA_20140522.shp'
# field name to use for file names
fieldName = "FID"

# set overwrite environment
arcpy.env.overwriteOutput = True

# loop through features
for row in arcpy.da.SearchCursor(polyFC, ["SHAPE@", fieldName]):
    # make new filename based on field value
    newName = os.path.join(os.path.dirname(polyFC), str(row[1]) + ".shp")
    # copy features to new file
    arcpy.CopyFeatures_management(row[0], newName)
phloem
  • 4,678
  • 15
  • 30
  • Some work but some give this error. Error opening feature class. Number of shapes does not match the number of table records. It appears the dbf and the .shp have lost the 1-1 match. Only on a few output shapes. – If you do not know- just GIS Sep 23 '14 at 19:32
  • Close enough so I accepted. – If you do not know- just GIS Sep 23 '14 at 19:50
  • Agreed, my answer is certainly not perfect. For example, it will fail if polyFC is a GDB feature class, resulting in an output called something like, "C:/junk/geodatabase.gdb/feature.shp". There are also differences between valid filenames and valid field values (converted to filenames) that may cause issues. I'm sure there are other catches, as well. – phloem Sep 23 '14 at 19:55
1

I would suggest using arcpy. Here is the general proposed code flow:

  1. Make feature layer of layer of interest
  2. Use search cursor on feature layer to get attribute of ID field and attribute of field for new shp name
  3. Use select by attribute method for each ID attribute for each row (i.e. unique feature)
  4. Create new feature class on selected feature layer using feature class to feature class method and reference value from name field for new shp name
artwork21
  • 35,114
  • 8
  • 66
  • 134
0

I went the model builder route.

This seemed to work.

enter image description here

The input shapefile is A I then iterated through Features while setting the %Value% As the attribute.

Then used FC to FC tool with the output name as %Value%.shp

Phoelm ArcPy (alternate comment and answer) worked on 90% of the files but see the comment for a strange error on a few of them.