[GIS] Automatically Remove Duplicate Vertices in a Polyline

arcgis-desktopvertices

I am trying to automatically identify identical vertices within a polyline and remove them without converting the vertices to points first. I have converted the vertices to XY points and identified a significant number of identical vertices, greater than 4000, that will need to be removed. I believe I can use itertools combined with a search cursor and an update cursor using the SHAPE@ variable to identify identical vertices and delete one. I have tried various bits of code and methods, but with little success. Using itertools "overlap" did not identify the identical points in XY so I believe I will need to use the itertools "equal", but am really a bit lost at this point. I am using ArcGIS 10.2.2 and do not have access to any extensions. I would like to incorporate this into a larger Python script I am writing.

Best Answer

There are several ways of doing this. If you know ArcObjects and a bit of VBA you could knock a simple update script together calling the ITopologicalOperator.Simplify() method. But you mentioned python so I guess ArcObjects is not a solution for you?

Well how about this: create an update cursor python script which steps through, gets the polyline geometry explodes that into an array of X,Y then add these to a Set, duplicates are removed when adding to a Set then reconstruct the array and turn that back into a polyline which you use to update the geometry? That would be a python solution that you could wrap into a python script tool.

Related Question