I have a line
layer and point
layer on my ArcGIS project. The points are on the lines. I want to create vertex on lines at this point coordinates.
import arcpy
point_rows = arcpy.da.SearchCursor("D:\Test.gdb\MyPoints", ['OID@', 'SHAPE'])
rows = arcpy.UpdateCursor("D:\Test.gdb\MyLines")
for row in rows:
geom = row.SHAPE
for part in geom.getPart():
for pnt in point_rows:
row.X = pnt.X
row.Y = pnt.Y
rows.updateRow(row)
I could not add vertex on points, if point is on the line. How can I do this using arcpy?
Best Answer
Below is some python code that will take an un-ordered set of polylines with zero or more intersecting points and insert a vertex into the polyline at the point position.
Sample data
This code is designed to be dropped into the Python console in ArcMap, simply change
lineLayer
andpointLayer
.