0

I am trying to adapt the "Batch clip in ArcGIS 10" script I found on GIS.StackExchange to my needs. I would like to do this in Python as a learning experiment. My data:

  • Point data
  • Standard numbered grid

My goal is to output point_1, point_2, point_3, {...}, point_n

Help me think about the problem. Since I'm not going to be "clipping" polygon data, can I accomplish this with a batch select? I've been doing some reading about batch clips, but have not written anything useful yet.

  • So you have a point file with say >10 points and want to export each point that falls in each grid cell? Am I understanding this correctly? – GISKid Nov 29 '13 at 15:22
  • @GISKid exactly. The data is on GitHub – Elliott Nov 29 '13 at 15:31
  • Could you do something like a search cursor, selecting each cell by row, then select by location on your points --> export? – GISKid Nov 29 '13 at 16:18
  • 2
    If you have an ArcInfo license, the Split_Analysis tool would work great for this. See the answer by @polygeo in the question you referenced above. – RyanDalton Nov 30 '13 at 2:13
3

Elliot, instead of clipping you can use the select by location and select by attribute geoprocessing tools to get what you want accomplished. I.e. Loop through the polygon grid and select each one by attribute - then select which points fall within each selected polygon - and copy them to a new point feature class. I might look something like this.

# Make Feature Layers
arcpy.MakeFeatureLayer_management("NAME OF POLYGON DATASET", "polylyr")
arcpy.MakeFeatureLayer_management("NAME OF POINT DATASET", "pntlyr")
# loop through the unique list of polygons
for x in range(1,100):
    # Select Polygon Layer
    arcpy.SelectLayerByAttribute_management("polylyr", "NEW_SELECTION", "ID = " + str(x))
    # Select Intersecting Points
    arcpy.SelectLayerByLocation_management("pntlyr","INTERSECT","polylyr", "#", "NEW_SELECTION")
    # Copy Selected points to new shapefile in C:\temp folder
    arcpy.CopyFeatures_management("pntlyr", "c:/temp/point_" + str(x) + ".shp")

Hopefully this works for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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