180 + math.atan2((!Shape.lastpoint.Y! - !Shape.firstpoint.Y!),(!Shape.lastpoint.X! - !Shape.firstpoint.X!)) * (180 / math.pi)
def NorthAzimuth(Pline): degBearing = math.degrees(math.atan2((Pline.lastPoint.X - Pline.firstPoint.X),(Pline.lastPoint.Y - Pline.firstPoint.Y))) if (degBearing < 0) : degBearing += 360.0 return degBearing
You can try this formula :
It's works great for medef NorthAzimuth(Pline): degBearing = math.degrees(math.atan2((Pline.lastPoint.X - Pline.firstPoint.X),(Pline.lastPoint.Y - Pline.firstPoint.Y))) if (degBearing < 0) : degBearing += 360.0 return degBearing
Parser: Python Expression: GetAzimuthPolyline(!Shape!) def GetAzimuthPolyline(shape): degBearing = (math.degrees(math.atan2((shape.lastPoint.X - shape.firstPoint.X),(shape.lastPoint.Y - shape.firstPoint.Y))))+90 if (degBearing < 0) : degBearing += 360 return degBearing