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
Property | Explanation | Data 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 |
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 |
useHierarchy (Read Only) | Indicates whether the travel mode uses a hierarchy attribute while performing the analysis. The following is a list of possible values:
| 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:
| 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:/data/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")