Hello. I'm using arcgis pro. I try to use Python to write codes to perform closest facility analysis under the network analyst tool. I need to set the travel modes. The following website provides the sample codes to update travel modes through python:https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/travelmode.htm
If you look at the screenshot, the mode is gray at the top left corner. When I perform analyses in ArcGIS Pro by clicking buttons, I would go to travel settings and change the impedance. That lets me to choose whether I want to use distance or time to perform optimization.
The sample codes from https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/travelmode.htm that I use are the following:
import arcpy
network = r"C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
travel_modes = arcpy.na.GetTravelModes(network)
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("")
According to the codes, to set the impedance, I have to use travel_mode.impedance. However, the travel_model I get using "travel_modes = arcpy.na.GetTravelModes(network)" is {}, which is blank.
Can anyone tell me how I could set impedance through python even if the travel modes for my network data set is an empty set? Thank you.