Select to view content in your preferred language

In Network Analyst Routing, how do you get turn delays to work?

4776
11
05-10-2018 09:37 AM
BradSrebnik
Occasional Contributor

I am trying to get turn delays to work in Network Analyst Routing.  My numbered questions are in bold below.  I have read all the articles I can find in ESRI help on turns, global turn delays, etc.

I created a Network Dataset from a Roads feature class.  With help on this community board, I was able to customize the Length attribute to control how the routing was done.  I did this with a Python script in Field Evaluators for the attribute.

Now I want to add a bigger penalty for left turns.  Question #1:  Should I care if I use global turn delays or is there a non-global turn delay?  How would I decide which I should use?

I thought I needed to add a Turn feature class  (Question #2:  Do I need to?  How would I decide?), so I did so with the Creature Turn Feature Class (Network Analyst) tool.  I did not use a template.

Then I added the Turn feature class to the Network Dataset.

Now I tried 10 different ways to set a longer delay for left turns using Script Evaluators for the Turns in my Length Attribute.  It always seemed to ignore what I did.  Re-building the dataset does not help.

Then I read (in a Community comment I think, not in help) that you have to set a time-base Cost as the Use by Default Cost Attribute to use turn delays.

Question #3:  Is this only true for using Global Turn Delays?

Question #4:  Are the non-default costs used or ignored?  Does it calculate the non-default costs, and then just make those values available for the default cost evaluation?  This does not appear to be documented at all.  I'd like to understand how all that works.

So I added a time-based Cost Attribute and set Use by Default.  I found the directions to get to the Global Turn Delay setting, and I tried setting all the left turn delays to a very long time (e. g., 600 seconds) so I could test a short route that could get to the destination using one or two left turns.  Screenshot of dialog attached.  No matter what I did, it always makes the route have two left turns.  It is even takes a longer route than it could.  See attached screenshot of route.  Re-building the dataset does not help. 

Question #5:  Am I doing the right things to get this working?  Any suggestions?

I'm happy to give more detail about anything I did if it will help answer my questions.

0 Kudos
11 Replies
JaySandhu
Esri Regular Contributor

Brad,

You ask a number of questions. So let me try to answer them.

Global turns are useful to specify overall trends, such as left turns take longer than right turns. They are important if you are trying to get accurate travel times. A turn feature class can be created so you can model turn restrictions or complex turns or specific turns. That is, a certain turn is not allowed or a turn at a complex intersections requires going through many edges to restrict a turning movement or some turn has an unusual delay that cannot be accounted for by the global turn penalties.

Delay, as the word implies has to do with time. It does not make sense if you are finding a shortest path based on length to also have a delay at a turn. How do you combine the two different costs? So have a cost attribute based on time (say in minutes) and make sure your turn delay are in the same units (i.e., minutes).

A shortest path solve will minimize the cost attribute you specify in the route analysis layer. The use by default makes it easy to say which one to use. Only one cost can be minimized. You can pick any non-default cost attribute to solve a shortest path.

As far as why the global turns are not getting used in your case, it could be way you have specified the cost attribute and then in using it with the route analysis solver.

One handy tool that you can use to see how the costs are setup is the Network Identify tool. It is the second icon from the right on the NA toolbar. You can add your network dataset to map, then use this tool to examine edges and see how they are connected to others and also see the cost values associated with them.

If you cannot get the global turns to work, I would suggest that you contact Esri technical support so that they may get your data and see what needs to be done to make it work.

Jay Sandhu

BradSrebnik
Occasional Contributor

Thanks for the reply, Jay.  I don't have access to my project at the moment, but will respond as best as I can.  Note that I do not have access to ESRI technical support with my student license.  I still have many questions.  Thanks for the tip on the Identify tool.  I will try that as soon as I can get back to the project.

I'm not sure I understand how a non-default cost is used at all.  If I have two Costs (one default, one not), and both are specified in minutes, does it add the cost for each Cost for each possible segment used in a route, or does it only use the default Cost calculation?  How do I "pick any non-default cost attribute to solve a shortest path" as you say above?

Anyway, since I tried just the Global turn delays, I'm still not sure what I should do differently to get them to have an effect.  Would more screenshots of my setup help?

So to summarize my main questions from the previous post with my best answers ...\

Question #1:  Should I care if I use global turn delays or is there a non-global turn delay?  How would I decide which I should use?  I think global turn delays (if I can get them working) should be sufficient.

Question #2:  Do I need to [add a Turn feature class]?  How would I decide? I still do not have any idea on this one.  Can I used the global turn delays without making a Turn feature class?

 

Question #3:  Is this [needing a time-based costs] only true for using Global Turn Delays?  I think it would also be true for non-Global Turn Delays?

 

Question #4:  Are the non-default costs used or ignored?  Does it calculate the non-default costs, and then just make those values available for the default cost evaluation?  I still don't know how this works.

0 Kudos
JaySandhu
Esri Regular Contributor

Brad,

I think you have some confusion over what is a "cost". When you create a network dataset, you specify the sources (like edges and turns, etc) that provide the geometry and topology rules. You also define "attributes" like costs, restrictions, etc. One cost could be traveltime and another Length. Then you specify how these will be populated from fields (or other types of evaluators) from the input sources. One of these costs can be marked as Use be default. When you create a route analysis layer, it will set the cost marked as use by default as the one to solve on. But you can bring up the properties of the route layer and pick a different one.

As far as question 2, you do not need a turn feature class to use global turns. Please read my detailed response in previous message that explained the difference between the two and when you need the turn feature class.

For more on question 4, I suggest you read more on network datasets:

What is a network dataset?—Help | ArcGIS Desktop 

And then I will suggest that you go through the Network Analyst tutorials that are available here:

About the ArcGIS Network Analyst extension tutorial—Help | ArcGIS Desktop 

Regards,

Jay Sandhu

BradSrebnik
Occasional Contributor

Thanks for the additional reply and clarifications.  The first paragraph would be a great addition to the help documentation.

So now I know I don't need a Turn feature class for my purposes, and the global turn delays should be sufficient.  I have removed that feature class from the network dataset and from the geodatabase, and re-built the dataset.

I have DriveTime as my default (I wish it was call "current" not "default") Cost Attribute.  For testing purposes, I have both edge Evaluators set to a constant value of 0.  I only want to take the turns into account to try to get that part working.  See first attached screenshot.

Now I go to the Default Values tab so I can set up the global turn delays:

And here are the long left turn delays:

Now it says the Dataset is already built so I don't need to re-build it.  I solve for the same route as above and it still takes the long route with two left turns.  I tried to use the Network Identify Tool, but it doesn't seem to show anything about delays at turns.  Is there any way to view that information?  Here is a screenshot of a junction point, which also shows the route taken in the background:

So does anyone see anything I'm doing wrong?  Appreciate all the help!

0 Kudos
BradSrebnik
Occasional Contributor

PS  Here's the Travel Mode tab, in case that has a problem.  No parameter values are set up here.

0 Kudos
BradSrebnik
Occasional Contributor

PS  Setting the Global Turn Delay for left turns to -1 gives the same route solution.  I believe it should result in no solution, and this further indicates that it is not looking at the Global Turn Delay Evaluator (for some reason I have yet to figure out).

0 Kudos
BradSrebnik
Occasional Contributor

I think I figured it out.  For others fighting this problem, the final step to getting working is shown below.  Also see everything I did above.  I will now try to add this to my custom cost evaluators, re-purposed to time, not length calculations, as discussed here:

    Network Analyst and Script Evaluators: accessing attributes, get "network element evaluator erro...

Open the Network Analyst window with the button on the Network Analyst toolbar.

On the Analysis Settings tab, make sure that Impedance is set to your time-based attribute (DriveTime in my case).

I assumed that having only one Travel Mode (set in my Network Dataset properties) and having it have a cost-based impedance would make the routing cost analysis use time (not distance) cost.  But no.  You need to set the Analysis Settings Impedance as well. This is not mentioned in the "Establishing Global Turns" help page.  It is one of the steps in Exercise 3 of the "ArcGIS Network Analyst Tutorial" but even there it doesn't mention a relationship to Global Turns.

0 Kudos
JaySandhu
Esri Regular Contributor

Glad you figured it out! As I had mentioned before, you can have many costs in the network dataset. But for each routing analysis you have to pick the one you want to use. In your case, the global turns were associated with one of the costs. If you do not pick that cost to solve on then obviously the turn delays were not getting used.

Regarding the suggestion of current .vs. default. I think default is appropriate. It is a setting in the network dataset that acts as a hint to the route analysis layer to use it. But you can change the cost in the route analysis layer. That does not change any settings in the network dataset, i.e., the new cost picked for routing does not change the default settings in the network dataset.

Regards,

Jay Sandhu

BradSrebnik
Occasional Contributor

Thanks again.

I do note, however, that I'm not convinced that the routing takes the optimal route in all cases.  I have a simple test case, and have the penalty for left turns at 30 seconds, and for right turns, 5 seconds.  The route can either 1 left turn and 2 right turns, or vice versa.  So a difference of 25 seconds.  I have field evaluators for the edge costs (based on a number of factors).  With the Network Identify Tool I can add up the edge costs, correct?  The difference between the two possible routes on that score is less than 25 seconds.  So totaling everything up, it should use the route with less left turns, but it doesn't until the edge cost difference is much greater than 25 seconds.  But I'll double-check my calculations when I have more time...