Anyone have a code snippet I can use to accomplish this?
Solved! Go to Solution.
I'm currently answering a similar question here:
Re: How to calculate the angle of a line respect t... - Esri Community
Calculate Geometry Attributes can calculate Line Bearing, if that's what you need.
or old school
Solved: Calculating polyline azimuth - code error - Esri Community
I'm currently answering a similar question here:
Re: How to calculate the angle of a line respect t... - Esri Community
This is what I ended up going with. Thanks!
// get a list of line parts
var paths = Geometry($feature).paths
// for each part, loop through each segment and get its angle (arithmetic angle -> East=0°, North=90°)
var angles = []
for(var p in paths) {
var count_p = Count(paths[p])
for(var q = 1; q < count_p; q ++) {
var a = Angle(paths[p][q], paths[p][q-1])
Push(angles, a)
}
}
// get the mean arithmetic angle
var arith_angle = Mean(angles)
// rotate so that North = 0°
var north_arith_angle = arith_angle - 180
return north_arith_angle + IIF(north_arith_angle < 0, 180, 0)