Calulating number of turns along a route

2028
14
04-25-2012 03:00 PM
KateSchaefer
New Contributor II
Hello,

I'm am using NA's Closest Facility solver to calculate routes between incidents and the closest fire station. The processes works fine and I have about 385 different routes. Is it possible to calculate or find out the number of turns along each route? And better yet, whether it was a left or right turn? Any help would be greatly appreciated.

Thanks!
Tags (2)
0 Kudos
14 Replies
JaySandhu
Esri Regular Contributor
Are you looking at counting turns that may be part of a turn feature class? In that case if their are turn restrictions they will be avoided. Only turns that have delays assoicated with them may be traversed. In that case use the traversal addin to generate the feature classes, including turns, after your paths are solved.
http://resources.arcgis.com/gallery/file/ArcObjects-.NET-API-Code-Gallery/details?entryID=C8A2186E-1...

But if you are looking at simply "bends" along your paths, then you have to look at the geometry at each intersection to see if a "turn" is being made. One simple way to get this information reported is to get the directions of a route. It will report left and right turns. You can save the directions as text or XML. With XML you may be able to parse out what you need, but this may not be in the best way to summerize.

Can the network dataset you are using to solve editable to add more attributes for later use? That may give more options on reporting turn information.

Jay Sandhu
0 Kudos
liemnguyen
New Contributor

Dear Jay,

Could you please share me the other link to download Traversal addin?

The current link has been broken.

Thank you so much!

0 Kudos
JaySandhu
Esri Regular Contributor

You can use the GP tool to get to the traversal results.

Copy Traversed Source Features—Help | ArcGIS Desktop 

0 Kudos
KateSchaefer
New Contributor II
Hi Jay,

Thanks so much! I installed and ran the Traversal Result tool and it gave me exactly what I needed. For others in the same boat, it creates (among other things) a "TRFC_Turns" feature class. This counted each intersection that the route took and gave me times for each intersection. Based on the times I was able to classify if the route went straight through the intersection or if it took a left or right.

Thanks again, this worked great!


Kate
0 Kudos
NagendraDhakar
New Contributor
Hi,
I am also trying to find no. of turns (left and right) along a route. But I have ArcGIS 9.3, and I guess, this add-in is for ArcGIS 10 as it doesn't recognize 9.3. So, it would be helpful for me if any one can please post the VBA code associated with the add-in?
Also, I know that turns can be accessed via traversal but when I use that with my network data set it gives me a blank shapefile, however, junctions and edges outputs are perfectly fine. That left me wondering if it has anything to do with the way I set up my turns while creating the network dataset. That time, I checked "Yes" to the question "Do you want to model turns in this network?" with "Global turns" checked as the turn sources. Also, at the end, I established driving directions by just providing "Street Name Fields". Alternatively, I tried using INAStreetDirectionsAgent, but it gives me the directions in XML output. I couldn't find any other useful output from that. Even, with the XML output I don't know how to use it to get the number of turns.

Any help is appreciated.

Thanks,
Nagendra
0 Kudos
JaySandhu
Esri Regular Contributor
The VAB is posted below. It will work for turns if they exist in your data.
Jay Sandhu

Public Sub AddNATraversalResultToArcMap()
  Dim pMxDoc As IMxDocument
  Dim pNetworkAnalystExtension As INetworkAnalystExtension
  Dim pNALayer As INALayer
  Dim pFLayer As IFeatureLayer
  Dim pTraversalResultQuery As INATraversalResultQuery
  Dim pNATraversalResultEdit As INATraversalResultEdit
 
  Set pMxDoc = ThisDocument
  Set pNetworkAnalystExtension = Application.FindExtensionByName("Network Analyst")
  Set pNALayer = pNetworkAnalystExtension.NAWindow.ActiveAnalysis
  Set pTraversalResultQuery = pNALayer.Context.Result
  Set pNATraversalResultEdit = pTraversalResultQuery
 
  'Infer Geometry
  pNATraversalResultEdit.InferGeometry "", Nothing, New CancelTracker
 
  'Get the Edges and add as a layer
  Set pFLayer = New FeatureLayer
  Set pFLayer.FeatureClass = pTraversalResultQuery.FeatureClass(esriNETEdge)
  pFLayer.Name = pFLayer.FeatureClass.AliasName
  pMxDoc.FocusMap.AddLayer pFLayer
 
  'Get the Junctions and add as a layer
  Set pFLayer = New FeatureLayer
  Set pFLayer.FeatureClass = pTraversalResultQuery.FeatureClass(esriNETJunction)
  pFLayer.Name = pFLayer.FeatureClass.AliasName
  pMxDoc.FocusMap.AddLayer pFLayer
 
'Get the Turns and add as a layer
  Set pFLayer = New FeatureLayer
  Set pFLayer.FeatureClass = pTraversalResultQuery.FeatureClass(esriNETTurn)
  pFLayer.Name = pFLayer.FeatureClass.AliasName
  pMxDoc.FocusMap.AddLayer pFLayer
 
End Sub
0 Kudos
NagendraDhakar
New Contributor
Hi Jay,
Thank you for the reply. I used the same VBA code for turns but output had nothing. Btw, if street directions are available doesn't it mean that turns are there too? if not then do we have to import turns separately?

Thanks,

Nagendra
0 Kudos
JaySandhu
Esri Regular Contributor
The street directions looks at every edge of a route as it connects to the next edge, computes the angle and then decides what angle exists before it can say left or right turn. As I mentioned, this VBA (or the new AddIn) export out the turn features that were part of the network dataset. it cannot export what does not exist. You will have to post process the Edges that are exported out of here to determine left/right turns.

Jay Sandhu
0 Kudos
NagendraDhakar
New Contributor
Hi Jay,
Then is there any way to get these turns through street direction? I can export the directions as a XML output but how can I get left and right turns from that? If i try to calculate angles between edges than it will increase the computing time. So, I am thinking if there is something in the results that can be used for this.

Thanks,

Nagendra
0 Kudos