GetTravelModes

Titleā€ƒ GetTravelModes

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


Syntax

Code Samples

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

Tags

Credits

Use limitations