Summary
Get a list of travel modes configured for your organization that can be used with ArcGIS Online network analysis services. A travel mode represents a means of transportation, such as driving or walking. Travel modes are essentially templates consisting of a long list of travel settings.
Usage
- Upon execution, the tool adds a table, Supported Travel Modes, to the application. Any value in the Travel Mode Name field from the Supported Travel Modes table can be specified as input to the travel_mode parameter supported by various tools, such as FindRoutes, in the geoprocessing service. You can also specify the value from the Travel Mode Settings field as input to the travel_mode parameter. This speeds up the execution of the tool used, such as FindRoutes, because the tool does not have to look up the settings based on the travel mode name.
The tool does not support any input parameters
Syntax
arcpy.naagol.GetTravelModes()
Derived Output
Name | Explanation | Data Type |
supportedTravelModes | The list of supported travel modes. | List |
defaultTravelMode | The default travel mode for the service. | String |
Code sample
GetTravelModes example
The following Python script demonstrates how to use the GetTravelModes tool in a script.
'''
The script shows how to use the GetTravelModes tool to get a list of travel modes supported by your
ArcGIS Online organization.
'''
import sys
import arcpy
#Change the username and password applicable to your own ArcGIS Online account
username = "<your user name>"
password = "<your password>"
utility_service = "https://logistics.arcgis.com/arcgis/services;World/Utilities;{0};{1}".format(username, password)
#Add the geoprocessing service as a toolbox.
arcpy.ImportToolbox(utility_service)
#Call the tool
result = arcpy.Utilities.GetTravelModes()
#Print any warning or error messages returned from the tool
result_severity = arcpy.GetMaxSeverity()
if result_severity == 2:
arcpy.AddMessage("An error occured when running the tool")
arcpy.AddMessage(arcpy.GetMessages(2))
sys.exit(2)
elif result_severity == 1:
arcpy.AddMessage("Warnings were returned when running the tool")
arcpy.AddMessage(arcpy.GetMessages(1))
#Retrieve the travel mode table
output_tm_table = result.getOutput(0)
#Save the travel mode table in memory.
output_tm_table.save("in_memory/TravelModes")
#Use a cursor to build a list of travel mode names from the table
arcpy.AddMessage("Travel Modes configured for your organization")
travel_mode_names = []
with arcpy.da.SearchCursor(output_tm_table, ["Name"]) as cursor:
for row in cursor:
travel_mode_names.append(row[0])
arcpy.AddMessage(row[0])
Environments
This tool does not use any geoprocessing environments.