Synthèse
Provides read and write access to the properties of a travel mode.
Discussion
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.
Attention :
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.
Syntaxe
TravelMode ({template_travel_mode})
Paramètre | Explication | Type de données |
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 |
Propriétés
Propriété | Explication | Type de données |
attributeParameters (Lecture et écriture) | 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 could have a parameter to specify a weight restriction. | Dictionary |
description (Lecture et écriture) | A short text description of the travel mode. | String |
distanceAttributeName (Lecture et écriture) | 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 (Lecture et écriture) | 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. | String |
name (Lecture et écriture) | The unique name of the travel mode. | String |
restrictions (Lecture et écriture) | 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 certain characteristics. | String |
simplificationTolerance (Lecture et écriture) | 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 (Lecture et écriture) | 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 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 (Lecture et écriture) | Indicates the category of travel or vehicle represented by this travel mode. The following is a list of possible values:
| String |
useHierarchy (Lecture et écriture) | Indicates whether the travel mode uses a hierarchy attribute while performing the analysis. The following is a list of possible values:
| String |
uTurns (Lecture et écriture) | 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 |
Exemple de code
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.na.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("")
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.na.GetTravelModes(network)
# Construct a new TravelMode object from the existing Driving Time travel mode
new_travel_mode = arcpy.na.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 creating an OD cost matrix analysis layer
arcpy.na.MakeODCostMatrixAnalysisLayer(network, "OD Cost Matrix", new_travel_mode)
Vous avez un commentaire à formuler concernant cette rubrique ?