Select to view content in your preferred language

arcpy.nax does not use travel modes as specified in ND properties

622
3
09-28-2023 08:52 AM
RavenSchmidt
Emerging Contributor

The travel modes of my network dataset work correctly in ArcGIS Pro, but do not work using python arcpy.nax. Is there something wron in how I call them up in my script or are there some informations from the properties that are not used by arcpy and have to be manually recreated?

nd_travel_modes = arcpy.nax.GetTravelModes(network_layer)

for mode in nd_travel_modes:

# Set properties.
service_area.timeUnits = arcpy.nax.TimeUnits.Minutes
service_area.defaultImpedanceCutoffs = [10, 20, 30]
service_area.travelMode = mode
service_area.outputType = arcpy.nax.ServiceAreaOutputType.Polygons
service_area.geometryAtOverlap = arcpy.nax.ServiceAreaOverlapGeometry.Overlap
##### Load the inputs. #####
input_facilities = r"C:\Users\callt\Desktop\oS\psX\projects\1238 Warendorf\data\analysis\p30\1238_data.gdb\koordinaten_betriebe"
service_area.load(arcpy.nax.ServiceAreaInputDataType.Facilities, input_facilities)

##### Solve the analysis. #####
result = service_area.solve()
0 Kudos
3 Replies
MelindaMorang
Esri Regular Contributor

It looks to me like this code should work.  However, I can't see where you created the Service Area object (that's probably not the issue).  What results are you seeing that tell you the travel mode isn't working correctly?  Can you give some more details or post some screenshots?

0 Kudos
RavenSchmidt
Emerging Contributor

RavenSchmidt_0-1695984174554.png

Green is not a line but the correct service area polygon.
Pink is the result when I use arcpy.nax for the same analysis. It seems to ignore my prohibitions (bus is only supposed to use bus line)

 

0 Kudos
MelindaMorang
Esri Regular Contributor

A couple of other questions:

  1. I can't see from your code snippet where you save the resulting Service Area polygons.  Are you using the export() method?  This might be a dumb question, but are you sure you're saving the result of each iteration to a separate feature class and looking at the right one in the map?  What happens if you run the script with just one travel mode (the one for bus that you're having trouble with)?
  2. Are you sure the points you're using as inputs are locating in the desired place on the network?  Are you using some network location settings in Pro that you're not using in your script?
  3. Are you sure it's really working as intended within the Pro UI?  Can you paste a screenshot of your layer's analysis settings and your network dataset configuration (connectivity policies, travel mode and attribute configuration)?
0 Kudos