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"
# Get all travel modes from the network dataset
travel_modes = arcpy.na.GetTravelModes(network)
# 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(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.
Solved! Go to Solution.
That's correct. Feature Class To Feature Class and Copy Features do not work with network datasets. There is no way to convert or export a shapefile network dataset. You have to recreate it from scratch in a file geodatabase. Here is the procedure:
Thank you for your detailed explanation. Now I'm following the steps in https://pro.arcgis.com/en/pro-app/latest/help/analysis/networks/how-to-create-a-usable-network-datas... to create a new network datasets after importing the two shapefiles into a geodatabase.
However, I encountered another problem. The sources of the original network dataset is la_streets_clip_UTM, and la_streets_clip_UTM_ND_Junctions (source in the original dataset.png). Therefore, I use these two sources to create a new network dataset called la_ND (create network dataset.png). However, a default junction file is automatically created, whose name is la_ND_Junctions. And I am unable to uncheck it through Add/Remove Sources (cannot remove default junction.png), nor am I able to delete it through the catalog pane. I was wondering how I should approach this issue. Thank you.
When you create and build a network dataset, the build process automatically generates a feature class of "system junctions". These are point features representing locations in the network where edges intersect. You should not edit or remove or interact with this auto-generated feature class. It's just there so everything else will work right.
In your old shapefile network, la_streets_clip_UTM_ND_Junctions is probably the auto-generated system junctions. Don't bother exporting that or using it to create your new network. Just leave it out. Then, when you run Build Network to build your new network, it will auto-generate a fresh system junctions feature class. This is the expected, correct behavior.
Thank you. I just constructed a new network dataset from the original shapefile, and was also able to create travel modes. The new network dataset worked well in ArcGIS Pro. Thank you so much for your help along the way. I really appreciate it.