I had been in need of a tool with that capability. That sure beats using the deflection tool to figure it or exporting out a shapefile and measuring in AutoCad.
I know you're looking for a tool to do this one at a time, but this script will calculate all turn angles along all lines (in a feature layer called "line" below), in a newly created in_memory point feature class (called "points" below), in a field called, "Angle":
>>> import math
... sr = arcpy.Describe("line").spatialReference
... insCur = arcpy.da.InsertCursor("points",('SHAPE@','Angle'))
... with arcpy.da.SearchCursor("line",["SHAPE@"]) as cursor:
... for row in cursor:
... for part in row:
... pt_count = 1
... for pnt in part:
... pnt = arcpy.PointGeometry(pnt,sr)
... if pt_count > 1:
... if pt_count >2:
... distAB = oneBack.distanceTo(twoBack)
... distBC = pnt.distanceTo(oneBack)
... distAC = pnt.distanceTo(twoBack)
... angB = math.degrees(math.acos((((distAB*distAB)+(distBC*distBC))-(distAC*distAC))/(2*distAB*distBC)))
... twoBack = oneBack
... oneBack = pnt
... pt_count += 1
... del insCur
Thank you very much for sharing this script to calculate the deflection angles of a line. I am inexperienced with arcpy, but have been expanding my understanding daily. Finally, in the past week, my understanding of the integration of Python in ArcGIS allowed me to understand your script. After some manipulation to meet my needs, it works! Thanks again.
This script appears to very close to what I need for results which is comparing vertices on a line (transmission line with transmission poles being the nodes) and measuring the angle between each line segment (vertex) and if greater that 30 degrees, label that line segment (vertex).
Is this something you could spin up?
Many thanks in advance!
In the above message, I used the term vertex incorrectly. What I meant to say was "the line segment in between vertices".
You're a king! Thank you!
Retrieving data ...