I have a shapefile of lines. I want the angle of every line calculated in a field.
I am using the script below in arcmap, but when it encounters a line that is horizontal, it stops calculating any remaining values and gives the following error:
The field is not nullable.
I searched for answers to similar questions, not getting too far with them.
Where I originally found this code: https://geonet.esri.com/thread/20473#21719
Pre-logic Script code:
import math def GetAzimuthPolyline(shape): radian = math.atan((shape.lastpoint.x - shape.firstpoint.x)/(shape.lastpoint.y - shape.firstpoint.y)) degrees = radian * 180 / math.pi return degrees