You can do that with some arcpy.
1) You need to do the Spatial Join between the points and the lines to transfer the ID value of each line to each point.
2) Find out the closest vertex of the line and the input point.
3) Calculate the direction of this segment.
4) Update the rotation field of the points (with joined line ID).
import arcpy
import math
def GetAzimuthPolyline(firstPoint,lastPoint):
radian = math.atan((lastPoint.X - firstPoint.X)/(lastPoint.Y - firstPoint.Y))
degrees = radian * 180 / math.pi
return degrees
spatial_reference=arcpy.SpatialReference(3857)
lines_fc = r"C:\GIS\Temp\ArcGISHomeFolder\Default.gdb\_lines"
pnts_fc = r"C:\GIS\Temp\ArcGISHomeFolder\Default.gdb\_points_SpatialJoin2"
lines = [f for f in arcpy.da.SearchCursor(lines_fc,["ID","SHAPE@"],None,spatial_reference)]
pnts = [p for p in arcpy.da.SearchCursor(pnts_fc,["ID","SHAPE@"],None,spatial_reference)]
line_vertices_dict = {line[0]:line[1].getPart(0) for line in lines}
#finding out which vertex of the line is the closest to each of the
#points - to calculate direction later
nearest_vertex = dict.fromkeys([pnt[0] for pnt in pnts])
for pnt in pnts:
vertex_tuple = line_vertices_dict[pnt[0]]
vertex_id = 0
for vertex in vertex_tuple:
distance = round(pnt[1].distanceTo(vertex),2)
if not nearest_vertex[pnt[0]]:
nearest_vertex[pnt[0]] = ({vertex_id:distance})
if vertex_id == 0:
if distance < nearest_vertex[pnt[0]][vertex_id]:
nearest_vertex[pnt[0]] = ({vertex_id:distance})
else:
if distance < nearest_vertex[pnt[0]].values()[0]:
nearest_vertex[pnt[0]] = ({vertex_id:distance})
vertex_id += 1
print nearest_vertex
#{u'A1': {0: 157.06},
#u'C3': {3: 553.08},
#u'D4': {0: 244.37},
#u'E5': {1: 271.14},
#u'B2': {1: 779.33}}
#creating a dictionary of line directions - to be used for point symbols rotation
angles_dict = {pnt[0]:
GetAzimuthPolyline(pnt[1].firstPoint,line_vertices_dict[pnt[0]]
[nearest_vertex[pnt[0]].keys()[0]]) for pnt in pnts}
#calculating the direction of the segment connecting the symbol point and the nearest vertex
with arcpy.da.UpdateCursor(pnts_fc,["ID","RotatField"]) as upd_cur:
for row in upd_cur:
row[1] = angles_dict[row[0]]
upd_cur.updateRow(row)
This is how it might look: