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?

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

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

  • That did the trick! – joosthoek Jan 25 '13 at 11:43

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.