# Adding vertices to lines at specific x,y coordinates and move these new vertices to change polyline shape

I have a map of a power grid and a feature class containing all secondary conductors that are overlapped by a primary conductor. For connectivity to remain uninterrupted and avoid a loop in the circuit, I have to offset these overlapped secondary conductors. I want to add a vertex at 5 ft from one endpoint, another vertex 5 ft from the opposing endpoint, and then move these vertices 5 feet away from their original location. The end result should look something like this (a rough example I created manually):

Where green line is primary conductor, black line is secondary conductor, blue hexagon is a transformer (endpoint), and red dot is a meter (other endpoint). The line also needs to be "unsnapped" from the meter to interrupt power flow, eventually, but for now adding and moving vertices is the main goal.

I can extract the x,y coordinates of points 5 feet from each endpoint by making copies of the secondary conductors, trimming them using SegmentAlongLine, and adding LINE_START_MID_END geometry to the trimmed segments but how do I add vertices at these coordinates once I have them?

I'm thinking moving them will require some math as every polyline is at a different angle. Perhaps I could do the math beforehand to save a step, and adding the vertices at the offset location will give me the shape I desire. I have about 800 polylines to offset.

I'm using ArcMap 10.6.1 on a basic license.

If the existing features are all straight lines with no vertices in between the end points, then you could construct python code that would do the math of it for you. It's a little involved, but doable. Figure out the angle of the line by theta = math.atan((y2 - y1) / (x2 - x1)). (You'll have to precede that by testing if x2 == x1 and if so, theta = pi/2 if y2>y1 and -pi/2 if y2<y1.)

Then you need to figure out which way the angle is facing. The atan function assumes that the angle is the one facing to the right. So if x2 >= x1, then coords of the new vertex are xnew = x1 + (5 * math.cos(theta)) and ynew = y1 + (5 * math.sin(theta)). If x2 < x1, then both plus signs become minus signs.

To move the new vertex, you would need to repeat that calculation using either (theta + (math.pi / 2)) or (theta - (math.pi / 2)). Depending on which way you want to shift the points. And make sure you shift the points on both ends in the same DIRECTION, which means rotating the angle the OPPOSITE way because you are facing the opposite way. You will need to figure this out in two or four cases, depending on which quadrant you are in relative to x,y.

And test all of this math. I'm doing it in my head.

``````if x2 == x1:
if y2 > y1:
theta = math.pi / 2
else:
theta = math.pi / -2
else:
theta = math.atan((y2 - y1) / (x2 - x1))
if x2 < x1:
xnew = x1 - (5 * math.cos(theta))
ynew = y1 - (5 * math.sin(theta))
else:
xnew = x1 + (5 * math.cos(theta))
ynew = y1 + (5 * math.sin(theta))

# (then do similar to move the point with math.cos(theta + (math.pi / 2)) and so forth
``````

you can approach the problem in a easy way.

1. made buffer from the the point (5ft diameter)
2. trasform buffer in line
3. intersect line buffer with your conductor line to have a point at 5ft from the end, done.

take care of attributes during the operation.