# Calculating incidence angle of polyline?

How can I calculate the angle of each polyline in ArcGIS?

• This is an old question, but I am wondering what you mean by "the angle of each polyline" - is it the angle of a straight line from the start to end node of that polyline, or the angle of every segment in that polyline? A picture included in your question would clarify this. – PolyGeo Sep 24 '14 at 23:56

I found a similar question on an ESRI forum that had a good answer. The image below shows a sample polyline dataset to test the field calculator on. The attached code block below calculates the degrees from the x-axis. Try the following steps:

1. Use the Split Line at Vertices tool to create individual line segments from your poly line.
3. Right-click the "angle" field name header and open the field calculator
4. Add the python code to the code block as in the example and click OK
5. You may need to alter the code to meet you specific needs, but this will get you started.  • You should be using atan2 – Mike T Dec 16 '12 at 20:34

Additional to Aarons correct answer here the a way to use atan2 as suggested by Mike T and the transformation to geographical Degrees where the geographical North is at 0/360°.

``````# Pre-Loci Script Code
import math
def GetGeographicalDegrees(shape):
shape.lastpoint.x - shape.firstpoint.x)
degrees = 360 - ( radian  *  360) / ( 2 * math.pi  )
else:
degrees = 360 - ((2* math.pi + radian  ) * 360) / ( 2 * math.pi  )
return degrees

# angle =
GetGeographicalDegrees( !SHAPE! )
`````` Example: Took me two days to figure this out. I needed to calculate the bearing of line segments comprising polygons *(think rays of the sun radiating from outside of sphere).This python code calculates a bearing wherein N=0; E=90; S=180; W=270. This is the same as Aaron's workflow (Dec 15 2012): 'add field', 'calculate field', etc. However, this yields a continuous 0-2pi radians value corresponding to a standard bearing on a compass. Much easier to interpret and work with than other answers I have seen. Much appreciation to all the posts that helped me solve this one. Hope this helps!

Workflow with polygon

1. split lines tool
3. calculate value of field by adding below code to Codeblock, following Aaron's answer above (see snapshot of field calculator)
4. call function as Aaron did above

*note: convert to degrees if you need. This is in radians
*adjust indents if errors in field calculator

code block for 'calculate field dialogue box:

``````import math
Here is a graphic showing what an atan2 output looks like, overlain with a unit circle. 