Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- arcpy.env.workspace = "path\to\workspace\MaintenanceDivisions"
- arcpy.env.overwriteOutput=True
- #variables
- md = "MaintenanceDivisions.shp"
- out = arcpy.CreateUniqueName( "clipped.shp" )
- mfp = "dissolved.shp"
- try:
- #clip polygons from selected area
- rows = arcpy.SearchCursor(md)
- row = rows.next()
- for row in rows:
- feat = row.Shape
- arcpy.Clip_analysis([mfpd], feat, out, "")
- row = rows.next()
- except arcpy.ExecuteError as e:
- print(e)
- del rows
- import arcpy, os
- outws = r'C:temp'
- poly_single = r'C:temppoly_single.shp' # The polygon to be clipped
- poly_multi = r'C:temppoly_multi.shp' # The clip features
- rows = arcpy.SearchCursor(poly_multi)
- count = 0 # Start a counter to name output polygons
- for row in rows: # Loop through individual features of "poly_multi"
- out_poly = os.path.join(outws, "out_poly" + str(count)) # Assemble the output poly name and path
- arcpy.Clip_analysis(poly_single, row.Shape, out_poly)
- count = count + 1
- # Clean up...Not necessary using "with" statement used in arcpy.da module
- del row
- del rows
- import arcpy
- p1 = "C:/p1.shp" #Multiple polygons
- p2 = "C:/p2.shp" #Single polygon
- with arcpy.da.SearchCursor(p1, ("FID", "SHAPE@")) as p1_cur:
- with arcpy.da.SearchCursor(p2, "SHAPE@") as p2_cur:
- for r2 in p2_cur:
- for r1 in p1_cur:
- intersect = r2[0].intersect(r1[1], 4)
- arcpy.CopyFeatures_management(intersect, "C:/{0}.shp".format(r1[0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement