I am trying to delete extra vertex from polyline layer using points coordination's of second layer. My idea is to create from points layer array of coordination and then loop through each line and compare each vertex coordination with point array. Whenever is equal delete it and recreate line.
import itertools, arcpy arcpy.env.overwriteOutput = True line_FC = arcpy.GetParameterAsText(0) point_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") points = arcpy.CopyFeatures_management(point_FC, arcpy.Geometry()) for point in points: with arcpy.da.UpdateCursor(temp, ["SHAPE@"]) as uCursor: for line in uCursor: line = line diff = line.difference(point) if not line.equals(diff): parts = diff.getPart() if parts: joined = list(itertools,chain.from_iterable(parts)) poly_trimmed = arcpy.Polyline(arcpy.Array(joined)) uCursor.updateRow([poly_trimmed]) arcpy.CopyFeatures_management(temp, output)
I got error:
Traceback (most recent call last): File "C:\Users\Marry\Documents\Programowanie\del_vertex_outside_poly.py", line 20, in diff = line.difference(point) File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\arcobjects\arcobjects.py", line 1752, in difference return convertArcObjectToPythonObject(self._arc_object.Difference(*gp_fixargs((other,)))) ValueError: Failed to execute (Script).
What i am doing wrong?
I am using ArcGIS Pro 1.3.