Adding vertex set distance from first or last vertex in polyline?

For ArcGIS 10.1, is there a python script or tool that will add only one vertex (node) a set distance from the first vertex, or alternatively, a set distance from the last vertex for multiple polylines? The original vertices need to be retained for each polyline.

I have over 500 polylines and creating vertices individually in an edit session is taking forever!

• Would Densify help? It will add vertices every `x` units, but I don't think it'll stop at just one so may not entirely suit your needs. Note this modifies your data, it doesn't create a separate output
– Midavalo
Sep 15, 2016 at 19:02
• Perhaps you are thinking instead of "extending" the line to add another vertex/endpoint. I think a picture will make your question clearer.
– PolyGeo
Sep 15, 2016 at 19:18
• Only need to add a vertex within a polyline, not extend it or change its length. Sep 15, 2016 at 19:30
• How do you decide whether to place the vertex that set distance from the start vs the end or are you wanting both? Please keep clarifying via an edit to your question because potential answerers do not always have time to read comment trails.
– PolyGeo
Sep 15, 2016 at 20:13

1 Answer

1. Create a copy of your lines
2. Run add geometry attributes on it, part count and length
3. Select ones with length > limit and part_Count=1
4. Open table, select field Shape, pick field calculator, parser Python, advanced

Use expression below:

``````def insertV(dist,shp):
newP=shp.positionAlongLine (dist).firstPoint
n,arr,part=0,arcpy.Array(),shp.getPart(0)
m=len(part)
for i in range(m):
p=part.getObject(i); L=shp.measureOnLine(p)
if L>dist:
n+=1
if n==1:arr.add(newP)
arr.add(p)
return arcpy.Polyline(arr)
``````

---------------------------

``````insertV(100, !Shape! )
``````