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[0]
            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))

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.

  • How is this not a duplicate of gis.stackexchange.com/questions/227115/… ?
    – Vince
    Commented Feb 6, 2017 at 17:11
  • Because in previouse question i was trying to delete vertex using polygon feature here i am trying to do it using point feature where my not needed vertex are. So it is a similar problem but different metod.
    – Losbaltica
    Commented Feb 6, 2017 at 17:28
  • 1
    Intersection of a point and a line is mathematically unlikely. If you look at the difference operator documentation, you'll see line.difference(point) is not a legal operation.
    – Vince
    Commented Feb 6, 2017 at 17:34
  • Thanks, I did not know that. Is there a different way to to do it then?
    – Losbaltica
    Commented Feb 6, 2017 at 17:56
  • Compute distance between each vertex and point
    – FelixIP
    Commented Feb 6, 2017 at 19:21

1 Answer 1


This is an untested approach as I'm not at a machine with the right license. This could be done in model builder so no code.

  1. Convert or "explode" your lines to points using the Feature Vertices To Points tool
  2. Select the exploded points that intersect your points layer (you may need to apply a search distance)
  3. Delete the selection
  4. Run the Points to Line tool, according to help the default sort order is the order they are found so as long as the exploded points remain in row order this should work.

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.