I am trying to remove polyline vertex which are outside the buffer polygon and not creates new vertex on intersection.
I found a script which remove vertex but inside polygon. What is more it creates new vertex on intersection. It may help with this task.
import itertools, arcpy arcpy.env.overwriteOutput = True line_FC = arcpy.GetParameterAsText(0) poly_FC = arcpy.GetParameterAsText(1) output = arcpy.GetParameterAsText(2) #clone input lines to memory for fast processing temp = arcpy.CopyFeatures_management(line_FC, "in_memory/temp") polygons = arcpy.CopyFeatures_management(poly_FC, arcpy.Geometry()) for poly in polygons: with arcpy.da.UpdateCursor(temp, ["SHAPE@"]) as uCursor: for line in uCursor: line = line diff = line.difference(poly) #if the two lines are not equal, that means it intersected the polygon if not line.equals(diff): #the result of geometry.difference() is a multipart line of only those #parts that lie outside the polyon parts = diff.getPart() #if parts is empty that means the line is completely within the polygon #i.e., no difference if parts: #We'll need to "join" the end of part1 to the beginning of part2 #so we'll just flatten the list of lists joined = list(itertools.chain.from_iterable(parts)) #and create a new polyline object to update the shape poly_trimmed = arcpy.Polyline(arcpy.Array(joined)) uCursor.updateRow([poly_trimmed]) arcpy.CopyFeatures_management(temp, output)
Is there a way to do it in arcpy? I am using ArcGIS Pro 1.3.