8

I am looking for a way to split points by a county polygon feature class. The attached image shows two feature classes: one composed of points and the other a county polygon feature class. The split tool would be ideal if it allowed points. I would prefer a clean output without additional fields added to the point attributes. Additionally, I would like to have the county name from the polygon feature class defining the new point feature classes (e.g. Kiowa, Clark, Comanche). I appreciate any solutions and advice.

For this example, the final product should be three point feature classes named "Kiowa", "Clark" and "Comanche" produced from one, larger point feature class. An automated solution would be ideal, as I have many, many merged point FCs over dozens of counties to work with (approximately spanning the state of KS).

enter image description here

6
  • 3
    This operation is known to ESRI software users as a spatial join. Also see gis.stackexchange.com/questions/11047 and gis.stackexchange.com/questions/23398.
    – whuber
    Commented Sep 4, 2012 at 22:32
  • @whuber I envision at least 5 steps with the spatial join approach: 1) spatial join 2) select points based on county 3) create new FCs based on selection, 4) Rename FCs based on County 5) Delete new fields (e.g. "Join_count"). I need to find a way to automate the process (one of your links is promising). I was also hoping that I am overlooking a simpler approach similar to what "split" will accomplish for polygon feature classes. I'm afraid I may have to go the cursor route.
    – Aaron
    Commented Sep 4, 2012 at 23:42
  • Puis-je avoir le lien en langue française ?
    – user9993
    Commented Sep 5, 2012 at 12:28
  • Aaron, your comment doesn't quite match your question. The question does not appear to indicate that you want one output FC for each county. The other steps are unnecessary: once and for all, create a copy of the county FC whose only attribute is a county name. The spatial join to your points finishes the job. If you have first merged all the point datasets (which is a smart database design in general) then your entire project can be completed in just two steps: (1) spatial join (2) split the output by county name: see blah238's answer.
    – whuber
    Commented Sep 5, 2012 at 12:44
  • @KhalilouWAGUE le lien de la jointure spatial en fr help.arcgis.com/fr/arcgisdesktop/10.0/help/index.html#//…
    – geogeek
    Commented Sep 5, 2012 at 14:08

5 Answers 5

5

After using Spatial Join or Intersect to get the County name attribute onto each point, try using Dan Patterson's Split Layer by Attributes tool available on the Geoprocessing Model and Script Tool Gallery.

Alternatively you could use ModelBuilder to automate this using a different approach involving Select Layer by Location (click thumbnail for full image).

enter image description here

Lifted from this thread on the ESRI forums: Batch Selecting by Location and Exporting Shapefiles

0
3

Much easier to use the intersect command.
Turn off unwanted fields.
1. Intersect to a new output.
2. Join the output with the original oid.
3. Calculate a new field with the cnty name.

Check out ettools for some enhanced versions of spatial join and split by location.

2

From what I read I would just run an overlay (ArcToolbox Analysis Tools - Overlay - and either Identity, Intersect, or Spatial Join) of your points with a county polygon dataset. In ArcMap you could limit the fields displayed in the county layer to the field with the county name, and only that field would be added to the result. If even that added field is too much, calculate its values into the matching field in the points table and then delete the added field.

2

Using Python you can loop a "Select Layer By Location" to grab the points that overlap each countie, and then save it as a Shapefile. It would be something like this:

import arcgisscripting
# starts geoprocessing
gp = arcgisscripting.create()
gp.OverWriteOutput = 1

# Variable iniciation
points = u"Path for your point shape"
counties = u"Path for counties shape"
outDir = u"path for output directory"

#Load points as a layer
gp.MakeFeatureLayer(points, "points")

# Go county by county
rows = gp.searchcursor(counties)
row = rows.next()

# loop County by county overlap
while row.countyName: #adapt to your countie table of attributes
    # Make a layer from the feature class
    gp.MakeFeatureLayer(counties, "counties lyr", "[countieName]='" + row.countieName + "'")
    # Select all points that intersect the current countie polygon
    gp.SelectLayerByLocation(points, "intersect", "counties_lyr", 0, "new_selection")
    outSHP = outDir + row.counties + u".shp"
    gp.CopyFeatures_management(points, outSHP)
    print(outSHP)
    row = rows.next()
 # End of loop

 del rows, row, gp

 #END

I have not test it, You probably have to adapt it to your case.

Edit: Changed Select_analysis by CopyFeatures_management following @blah238 advice.

4
  • 1
    I would probably change Select_analysis to CopyFeatures_management or similar -- you are already doing the selection so it is redundant.
    – blah238
    Commented Sep 5, 2012 at 11:46
  • You are correct, tho the result is the same, I have edited it to make it more clear. Commented Sep 5, 2012 at 12:06
  • Thanks for this script. Is there a way to do this outside of local memory? The problem I encounter with my datasets is that 7.5 million points do not like to be added as a layer.
    – Aaron
    Commented Sep 5, 2012 at 13:10
  • You will add as a layer only a portion of the points (from each county). Running the script outside ArcMap, you won't even need to display them so it might work any way. But you can try another thing. Start by making a spatial (or intersect) between the points and polygons, this will create a temporary file with the point info + the county name. Then you loop the counties and use Select_analysis (SpatialJoint_temp, outSHP,"[countieName]='" + row.countieName + "'"). I think that will work too, but I don't know if it more or less efficient than the first solution. Commented Sep 5, 2012 at 13:35
0

There is now an eLearning video tutorial (not free, but relatively cheap) called Using ArcPy Cursors to Split by Attribute and Location that includes showing how to:

Write a Python script to split one feature class using a polygon feature class into one feature class per features found within each of its polygon locations

I think it addresses the requirements of this question.

Disclaimer: I am the author and presenter of this eLearning video tutorial

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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