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, VehicleRoutingProblemSolverProperties, or LocationAllocationSolverProperties) before solving a particular analysis.


One or more travel modes can be defined on a local network dataset or on a network data source from an ArcGIS Enterprise or ArcGIS Online portal or stand-alone ArcGIS Server site. 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 may have a parameter of type String called Travel Modes that can be populated with a list of travel mode names when 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, which 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. To get the localized name of a travel mode, use the name property of the travel mode object.


GetTravelModes (network_dataset_path)

The network dataset or service from which to retrieve travel modes. The argument can be specified using one of the following options:


A dictionary whose keys are the travel mode names and whose values are the travel mode objects.


GetTravelModes example 1

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 =
print(travel_modes['Walking Time'])
GetTravelModes example 2

Create a list of travel mode names on ArcGIS Online. The names can be localized depending on the user's account setting.

import arcpy

travel_modes ="")
travel_mode_names = [travel_modes[mode].name for mode in travel_modes]
GetTravelModes example 3

This sample shows how to get a travel mode from a network and print some of its properties.

import arcpy

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

# 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("Impedance:", travel_mode.impedance)
    print("Restrictions:", ", ".join(travel_mode.restrictions))
GetTravelModes example 4

This sample shows how to clone a travel mode from a network, update its properties, and use it in an analysis.

import arcpy

network = r"C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
# Get all travel modes from the network dataset
travel_modes =
# Construct a new TravelMode object from the existing Driving Time travel mode
new_travel_mode =["Driving Time"])
# Update the useHierarchy property to turn hierarchy off, and update the 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, "OD Cost Matrix", new_travel_mode)
GetTravelModes example 5

The following code sample shows how to call GetTravelModes for a routing service on a stand-alone ArcGIS Server site.

Learn more about how to specify a routing service info dictionary

travel_modes =
        "utilityUrl": f"",
        "authenticationInfo": {
            "username": "my_username",
            "password": "my_password"