there are two different field calculator expressions in this link
/blogs/dan_patterson/2016/09/01/distance-calculations-using-the-field-calculator
""" azimuth_to(shape, from_x, from_y)
input: shape field, from_x, from_y
returns: angle between 0 and <360 between a specified point and others
expression: azimuth_to(!Shape!, from_x, from_y)
"""
def azimuth_to(shape, from_x, from_y):
radian = math.atan((shape.centroid.X - from_x)/(shape.centroid.Y - from_y))
degrees = math.degrees(radian)
if degrees < 0:
return degrees + 360.0
else:
return degrees
Expression
azimuth_to(!Shape!,from_x, from_y)
Or this one
""" angle_between(shape)
input: shape field
returns: angle between successive points,
NE +ve 0 to 90, NW +ve 90 to 180,
SE -ve <0 to -90, SW -ve <-90 to -180
expression: angle_between(!Shape!)
"""
x0 = 0.0
y0 = 0.0
angle = 0.0
def angle_between(shape):
global x0
global y0
x = shape.centroid.X
y = shape.centroid.Y
if x0 == 0.0 and y0 == 0.0:
x0 = x
y0 = y
return 0.0
radian = math.atan2((shape.centroid.Y - y0),(shape.centroid.X - x0))
angle = math.degrees(radian)
x0 = x
y0 = y
return angle
Expression
angle_between(!Shape!)
You can mess around with them to get what you want in terms in terms of inputs and outputs.