I need to add vertices to existing lines at intersections, something like this:

enter image description here

I want to do this automatically, by Python script. I can get the coordinates (x,y) of intersections in very simple way:

fc = "outputLayer.shp"
cursor = arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"] )
for row in cursor:
    x, y = row[0]

I can get ID lines too. If I have coordinates, how to add vertex at exisiting line?

enter image description here

  • 2
    Do you need to add a vertex for both line segments or just one? – artwork21 Feb 3 '17 at 15:07
  • 1
    Have you look at geonet.esri.com/thread/88032 ? This may point you in the right direction – Midavalo Feb 3 '17 at 15:16
  • @artwork21 of course for both lines. – Lipstick Feb 3 '17 at 16:14
  • @Midavalo Thanks for link to the article - I will study it. – Lipstick Feb 3 '17 at 16:19
  • 3
    Planarize lines, then merge back together using some ID – Ben S Nadler Feb 3 '17 at 18:51

A non-python way would be to use a geodatabase topology rule. For this to work you need to import the shapefiles into a Geodatabase and Feature Dataset:

No topology, no vertice at intersection: enter image description here

Create a new topology rule (Must Not Intersect) by right-clicking the Feature Dataset, and validate:

enter image description here

Vertices at intersections (in both overlapping lines):

enter image description here


I think @BenSNadler is correct when suggesting:

Planarize lines, then merge back together using some ID

but my understanding is that Planarize is not a tool that you can use in a Python script so I think you should refer to Planarize tool in ArcPy? for the advice that Feature to Line (Data Management), which needs an Advanced level license, can be used instead.

Creates a feature class containing lines generated by converting polygon boundaries to lines, or splitting line, polygon, or both features at their intersections.


If you have a bunch that you want to do, I would suggest editing using the topology toolbar which has the planarize function. However, if you want to do it individually for a different purpose, you can do it in python manually since you have the coordinates (using mathematical xy-intercept calculations). The way I would set it up would be to make a separate series of lists that contains a pair of coordinates and a line ID and then I would run through that list looking for every two coordinate pairs that have intersecting envelops and check those to see if they intersect in the xy plane, if they do, then you could add that coordinate to your coordinate list and remake the two lines into four lines that are split at that coordinate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.