Resumen
Returns a dictionary of travel mode objects that are available with the network data source. The dictionary keys are the names of the travel modes, and the dictionary values are the travel mode objects. The travel mode objects can be used to update a solver properties object (RouteSolverProperties, ClosestFacilitySolverProperties, ServiceAreaSolverProperties, ODCostMatrixSolverProperties, or LocationAllocationSolverProperties) before solving a particular analysis.
Debate
One or more travel modes can be defined on a local network dataset, or on a network datasource from an ArcGIS Enterprise or ArcGIS Online portal. This function can be used to populate a value list with the available travel modes given a network data source. For example, a geoprocessing script tool can have a parameter of type String called Travel Modes that can be populated with a list of travel mode names once a network dataset has been selected on the tool dialog box.
If a network data source does not support travel modes, this function returns an empty dictionary.
To use GetTravelModes with a portal URL, you must be signed in to the portal.
ArcGIS Online user accounts can be configured to use different languages, and this changes the names of the available travel modes. To enable script writing functionality that works regardless of the language set for the user account, the dictionary keys returned by the GetTravelModes function always correspond to the English name of the travel modes. If you want to get the localized name of a travel mode, use the name property of the travel mode object.
Sintaxis
GetTravelModes (network_dataset_path)
Parámetro | Explicación | Tipo de datos |
network_dataset_path | A variable that references the catalog path of a network dataset, a network dataset layer object, or the URL of a portal configured with the network analysis services. The catalog path of a network dataset can be obtained from the dataSource property of a network dataset layer or a network analysis layer object. It can also be obtained from the catalogPath property of a network dataset Describe object. | String |
Tipo de datos | Explicación |
Dictionary | A dictionary whose keys are the travel mode names and values are the travel mode objects. |
Muestra de código
Get the travel modes in a network dataset and print the walking time travel mode.
import arcpy
nds = 'C:/Data/SanDiego.gdb/Transportation/Streets_ND'
travel_modes = arcpy.na.GetTravelModes(nds)
print(travel_modes['Walking Time'])
Create a modified version of a travel mode from the network dataset and use this travel mode when creating a new OD Cost Matrix layer.
Missing source code file
Create a list of travel mode names on ArcGIS Online. The names could be localized depending on the user's account setting
import arcpy
travel_modes = arcpy.na.GetTravelModes("https://www.arcgis.com/")
travel_mode_names = [travel_modes[mode].name for mode in travel_modes]