3

I have two shapefiles, one is polyline, the other polygon. For each polygon I would like to clip the polyline vectors inside. Using arcpy I already found part of a possible solution: https://gis.stackexchange.com/a/19934/6458

import arcpy

arcpy.env.workspace = r'D:\Projects\GDBs\slowbutter.gdb\IPAS'
rows = arcpy.SearchCursor('HspAOI')
for row in rows:
    feat = row.Shape
    arcpy.Clip_analysis('HspWBD_HU12', feat, 'HspWBD_HU12_' + str(row.getValue('NAME')), '')

This however would create a new shapefile per polygon. I have 8000 polygons and would have to merge these using arcpy.Merge_management().

Is there maybe a way to not have to merge 8000 separate shapefiles? I work with arcpy and ogr so the latter might also be an option?

2
  • Do your 8000 polygons have any overlap between them?
    – PolyGeo
    Commented Jan 25, 2013 at 10:35
  • No, they are equal-area triangle polygons which share edges but no overlaps.
    – joosthoek
    Commented Jan 25, 2013 at 10:45

1 Answer 1

2

Because your polygons do not overlap I think you should try Intersect from the Analysis toolbox.

1
  • That did the trick!
    – joosthoek
    Commented Jan 25, 2013 at 11:43

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.