# How to calculate cumulative angles on specific routes?

I am using Network Analyst extension in ArcGIS 10.4 (Windows 10 Pro 64bit) to calculate accumulative angles from Node 1 to Node 423 on the shortest path as shown in the left side of Figure 1. Network is built from Voronoi poligons which is converted into center line colored green, so it is actually composed of short segments connected each other. Length of the segments distributes from 0.00319 to 3.51153 which is used as distance impedance.

Figure 1. Network

Followings are the setting applied in Network Analyst:

Network attributes "Angle" is set as "Unknown" unit. Source values of "Angle" is set as 0 for all sources. Turn penalty is set as "Script" in default values.

VB script is set as below -

``````|||||||||||||||||||||||||

Pre-logic Script Code:

turnAngle = 0

a = Turn.Angle

If a > 330 And a < 30 Then

turnAngle = 0.001 'Straight

ElseIf a > 30 And a < 150 Then

turnAngle = 1 'Right-turn

ElseIf a >= 210 And a <= 330 Then

turnAngle = 1000 'Left-turn

Else
turnAngle=1000000 'U-turn

End If

|||||||||||||||||||||||||

Value = turnAngle

|||||||||||||||||||||||||
``````

In "OD Cost Matirx", "Length (Meters)" is set as impedance and "Angle" is marked in accumulation tab.
The result accumulative angles (Name = Graphic Pick 1-423) shows 160003000, which means 160 times of U-turn and 3 times of Left-turn (there are 163 vertices between node 1 to 423).

However, as shown in the Figure 1, there is no U-turn observed in the network though Left-turn may be possible on the way from 1 to 423 as center line skews at some sections.

Do you have any idea which can fix this problem?

Reference

I also built another simple network to confirm the calculation, the network composed of 5 nodes which are connected by straight (0.001) -> left-turn (1) -> right-turn (1000) -> right-turn (1000000). The result shows correct total angle as 1002, 1 time of right-turn and 2 times of left-turn, based on the same setting above.

I suppose short length of original network may cause the problem.

• Are you using the field calculator of ArcGIS Desktop or something else?
– PolyGeo
Commented Mar 22, 2017 at 20:17
• Thank you for pointing out missing information in my post. I am using ArcGIS 10.4 and calculation is done in OD Cost Matrix calculator in Network Analyst extrnsion instead of field calculator. I updated my post.
– HSJ
Commented Mar 22, 2017 at 23:28