darrochkaye

Calculate Direction/Angle of Polyline Feature Class Relative to North

Discussion created by darrochkaye on Jul 24, 2012
Latest reply on Sep 12, 2013 by jhalligan
Hi,

I am working with some cyclone data and I have plotted various tracks from a number of events. I would like to know the angle/direction of each segment of the line and I am unsure the best way to do this. Due to the nature of the data, it is imperative the angle must be in degrees relative to north, i.e. north = zero degrees.

I found this code below on another thread but it seems to be giving me the wrong results, e.g. a line which should have an angle of 180 degrees is calculated as 90 degrees, and another which should be around 60 degrees is 209 degrees - as you can see the error isn't consistent therefore I doubt it is the 180 variable as displayed in the code:

180 + math.atan2((!Shape.lastpoint.Y! - !Shape.firstpoint.Y!),(!Shape.lastpoint.X! - !Shape.firstpoint.X!)) * (180 / math.pi)


I am a Python novice (attending ESRI training course soon) but I do have XML and HTML code experience, so any help would be greatly appreciated.

Thanks,
DK

Outcomes