TravelMode

サマリー

Provides read and write access to the properties of a travel mode.

説明

The TravelMode object provides read and write access to the properties of a travel mode. Travel modes can be created on a network dataset or configured on a portal network service 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 used as input in network analysis problems to control travel behavior.

To use a travel mode in your network analysis, you can create a TravelMode object and modify its properties as needed.

The GetTravelModes function can be used to access the existing TravelMode objects on a network data source. You can use one of these existing TravelMode objects as a template when creating a new TravelMode object.

注意:

While it is possible to modify the TravelMode objects that you get from the GetTravelModes function, this is not recommended. Modifications to these TravelMode objects cannot be saved back to the network data source, and you may run into naming collisions if you use the modified TravelMode object in an analysis. As a best practice, always create a new travel mode from an existing travel mode and modify the properties of the new travel mode.

構文

TravelMode ({template_travel_mode})
パラメーター説明データ タイプ
template_travel_mode

An existing TravelMode object to use as a template for the one to be created. The new TravelMode object will be created with the same properties as the template object, except that the name property will be altered to include angle brackets indicating that the new travel mode is a copy. For example, if the template travel mode was named Driving Time, the new one will be named <Driving Time>.

If a template is not specified or a value of None is used, a blank TravelMode object will be created, and the values of all properties must be explicitly set before using the travel mode in a network analysis.

Object

プロパティ

プロパティ説明データ タイプ
attributeParameters
(読み書き)

Lists the parameterized attributes used by the travel mode. The property is 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. An empty dictionary means the travel mode uses the current default parameters of the network dataset.

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 evaluate to True, thereby restricting travel through the tunnel. Similarly, a bridge can have a parameter to specify a weight restriction.

To update an individual attribute parameter value from its default, you must retrieve the current attributeParameters value, update the desired value in the dictionary, and set the attributeParameters property to the updated dictionary. Individual attribute parameter values cannot be set directly.

attr_params = travel_mode.attributeParameters
attr_params[('Height Restriction', 'Vehicle Height (feet)')] = 12
travel_mode.attributeParameters = attr_params

Learn more about attribute parameters

Dictionary
description
(読み書き)

A short text description of the travel mode.

String
distanceAttributeName
(読み書き)

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 would set distanceAttributeName to a distance-based cost attribute, such as Meters.

String
impedance
(読み書き)

The network cost attribute used as impedance. This cost attribute is minimized while solving network analysis problems.

A travel mode that models car driving time would indicate a cost attribute that calculates 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 that calculates 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.

Learn more about cost attributes

String
name
(読み書き)

The unique name of the travel mode.

String
restrictions
(読み書き)

The list of the restriction attributes used when solving network analysis problems with this travel mode. An empty list, [], indicates that no restriction attributes are used for this travel mode.

Restrictions can prevent travel on roads with specific characteristics.

Learn more about restriction attributes

String
simplificationTolerance
(読み書き)

Specifies whether the travel mode generalizes the geometry of analysis results and by how much. The syntax is "<value> <units>", for example, "10 Meters". A value of None means that the geometry will not be simplified.

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
(読み書き)

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 describes how long it takes to move along network edges, even though distance is being minimized instead of time. For a walking distance travel mode, for instance, timeAttributeName would be set to a cost attribute that calculates walking times.

String
type
(読み書き)

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
(読み書き)

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.

Learn more about hierarchy

String
uTurns
(読み書き)

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 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

コードのサンプル

TravelMode example 1

This sample shows how to print properties from a TravelMode object.

import arcpy

network = r"C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
# Get all travel modes from the network dataset
travel_modes = arcpy.nax.GetTravelModes(network)

# Print the impedance attribute and restrictions used for each travel mode
for travel_mode_name in travel_modes:
    travel_mode = travel_modes[travel_mode_name]
    print(travel_mode_name)
    print("Impedance:", travel_mode.impedance)
    print("Restrictions:", ", ".join(travel_mode.restrictions))
    print("")
TravelMode example 2

This sample shows how to update TravelMode properties and use the updated travel mode in an analysis.

import arcpy

network = r"C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
# Get all travel modes from the network dataset
travel_modes = arcpy.nax.GetTravelModes(network)
# Construct a new TravelMode object from the existing Driving Time travel mode
new_travel_mode = arcpy.nax.TravelMode(travel_modes["Driving Time"])
# Update the useHierarchy property to turn hierarchy off, and update the name
new_travel_mode.name = "Driving Time without Hierarchy"
new_travel_mode.useHierarchy = "NO_HIERARCHY"
# Use the new travel mode object when constructing an OD cost matrix analysis
od_object = arcpy.nax.OriginDestinationCostMatrix(network)
od_object.travelMode = new_travel_mode