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 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.

Edit:

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

share|improve this question
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 Sep 4 '12 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 Sep 4 '12 at 23:42
    
Puis-je avoir le lien en langue française ? –  user9993 Sep 5 '12 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 Sep 5 '12 at 12:44
    
@whuber Thanks. Post edited to address comments. –  Aaron Sep 5 '12 at 13:20

4 Answers 4

up vote 3 down vote accepted

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).

Image

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

share|improve this answer
    
Excellent! Thank you, the script is just what I was looking for. –  Aaron Sep 5 '12 at 23:02

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
1  
I would probably change Select_analysis to CopyFeatures_management or similar -- you are already doing the selection so it is redundant. –  blah238 Sep 5 '12 at 11:46
    
You are correct, tho the result is the same, I have edited it to make it more clear. –  Alexandre Neto Sep 5 '12 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 Sep 5 '12 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. –  Alexandre Neto Sep 5 '12 at 13:35

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.