Skip To Content

TravelMode

Summary

Provides read access to the properties and values of a travel mode. The GetTravelModes function is used to obtain a TravelMode object.

Discussion

The TravelMode object provides read-only access to travel modes and the properties and values that define them. Travel modes are created on a network dataset and model a mode of transportation (car driving time, walking distance, truck driving time, truck driving time for a truck that has a height of 13 feet and a weight of 80,000 pounds, and so on). Once a mode is created, it can be applied to a network analyst layer using the layer's ApplyTravelMode method. Applying a travel mode allows you to skip the steps of defining the various individual properties that define a travel mode because the travel mode's property values override similar property values on the network analyst layer.

Properties

PropertyExplanationData Type
attributeParameters
(Read Only)

Lists the parameterized attributes used by the travel mode. The property returns a dictionary. The dictionary key is a two-value tuple consisting of the attribute name and the parameter name. The value for each item in the dictionary is the parameter value.

Parameterized network attributes are used to model some dynamic aspect of an attribute's value. For example, a tunnel with a height restriction of 12 feet can be modeled using a parameter. A vehicle's height in feet can be specified as the attribute parameter value. If the vehicle is taller than 12 feet, this restriction will then evaluate to True, thereby restricting travel through the tunnel. Similarly, a bridge could have a parameter to specify a weight restriction.

An empty dictionary means the travel mode uses the current default parameters of the network dataset.

Dictionary
description
(Read Only)

A short text description of the travel mode.

String
distanceAttributeName
(Read Only)

Indicates the distance-based cost attribute for reporting directions and for solving vehicle routing problems.

Even travel modes that model driving time and walking time travel modes would set distanceAttributeName to a distance-based cost attribute, such as Meters.

String
impedance
(Read Only)

Provides the ability to get the network cost attribute used as impedance. This cost attribute is minimized while determining solutions for network analysis layers.

A travel mode that models car driving time would indicate a cost attribute that stores the time it takes a car to traverse an edge or street segment. In contrast, a Walking Time travel mode would have a cost attribute storing the time it takes to walk along edges or streets. A distance-based cost attribute, such as Meters, would be set for either a Driving Distance or Walking Distance travel mode.

String
name
(Read Only)

The unique name of the travel mode.

String
restrictions
(Read Only)

Provides the ability to get a list of the travel mode's restriction attributes. An empty list, [], indicates that no restriction attributes are part of the travel mode.

String
simplificationTolerance
(Read Only)

Specifies whether the travel mode generalizes the geometry of analysis results and by how much. The syntax is "<value> <units>", for example, "10 Meters".

Larger simplification values result in reduced bandwidth requirements and rendering times, but the output line and polygon features aren't as clear, especially as you zoom in on the map. Output routes for walking modes are not typically simplified as much as they are for driving modes. Pedestrian routes are viewed at larger map scales, so more detail is needed for the route lines.

String
timeAttributeName
(Read Only)

Indicates the time-based cost attribute for reporting directions.

The values for impedance and timeAttributeName are typically the same when modeling time-based travel modes. When modeling distance-based travel modes, however, the timeAttributeName value would describe how long it takes the travel mode to move along network edges. For a Walking Distance travel mode, for instance, timeAttributeName would be set to a cost attribute storing walking times.

String
type
(Read Only)

Indicates the category of travel or vehicle represented by this travel mode. The following is a list of possible values:

  • AUTOMOBILE The travel mode is used to represent travel by automobile.
  • TRUCKThe travel mode is used to represent travel by truck.
  • WALKThe travel mode is used to represent pedestrians traveling on foot.
  • OTHERThe travel mode is used to represent some other category of travel or vehicle not described above.
String
useHierarchy
(Read Only)

Indicates whether the travel mode uses a hierarchy attribute while performing the analysis. The following is a list of possible values:

  • USE_HIERARCHY Uses the hierarchy attribute for the analysis. Using a hierarchy results in the solver preferring higher-order edges to lower-order edges. Hierarchical solves are faster, and they can be used to simulate the preference of a driver who chooses to travel on freeways over local roads when possible—even if that means a longer trip. This option is applicable only if the network dataset referenced by the network analysis layer has a hierarchy attribute. A value of True may also be used to specify this option.
  • NO_HIERARCHYDoes not use the hierarchy attribute for the analysis. Not using a hierarchy yields an exact route for the network dataset. A value of False may also be used to specify this option.
String
uTurns
(Read Only)

Provides the ability to get the policy that indicates how the U-turns at junctions that could occur during network traversal are handled by the solver. The following is a list of possible values:

  • ALLOW_UTURNSU-turns are permitted at junctions with any number of connected edges.
  • NO_UTURNSU-turns are prohibited at all junctions, regardless of junction valency (number of connected edges). Note, however, that U-turns are still permitted at network locations even when this setting is chosen; however, you can set the individual network locations' CurbApproach property to prohibit U-turns there as well.
  • ALLOW_DEAD_ENDS_ONLYU-turns are prohibited at all junctions, except those that have only one adjacent edge (a dead end).
  • ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLYU-turns are prohibited at junctions where exactly two adjacent edges meet but are permitted at intersections (junctions with three or more adjacent edges) and dead ends (junctions with exactly one adjacent edge). Often, networks have extraneous junctions in the middle of road segments. This option prevents vehicles from making U-turns at these locations.
String

Code sample

Travel mode example (Python window)

This sample shows how to print properties from a travel mode object.

#Import modules
import os
import arcpy

#Define variables
workspace = "C:/Sata/SanDiego.gdb"
nds = os.path.join(workspace, "Transportation", "Streets_ND")

#Get the travel modes from the network dataset
travel_modes = arcpy.na.GetTravelModes(nds)

#print the impedance and restrictions used by each travel mode
for travel_mode_name in travel_modes:
    travel_mode = travel_modes[travel_mode_name]
    arcpy.AddMessage("'{0}' Travel Mode".format(travel_mode.name))
    arcpy.AddMessage("=" * 15)
    arcpy.AddMessage("Impedance: {0}".format(travel_mode.impedance))
    arcpy.AddMessage("Restrictions: {0}".format(", " .join(travel_mode.restrictions)))
    arcpy.AddMessage("\n")