How to set more than one cost attributes

733
9
12-17-2019 01:43 PM
jianhedu
New Contributor

Hey, 

I am using arcpy.na.solve to find the best transit route using network converted from GTFS data.  I need two cost attributes to be combined: public transit time and walk time. How should I set up the travel mode? 

Here is what I use for public transit only (which works fine):

travel_mode = "Public transit time"

arcpy.na.MakeRouteAnalysisLayer('TransitNetwork_ND','Route',travel_mode)

Thanks

Jane

0 Kudos
9 Replies
MelindaMorang
Esri Regular Contributor

Hi Jane.  What do you mean by you "need two cost attributes to be combined"?

If you created your network dataset using the template provided with the tutorial in the ArcGIS Pro documentation, then the "Public transit time" travel mode is already configured to calculate walk time along streets and transit time along transit lines.  When you solve a network analysis problem (like a Route) using "Public transit time" as the travel mode, it finds the optimal solution by considering the time it takes to walk along streets and ride public transit.  You don't need to configure anything specific.

0 Kudos
jianhedu
New Contributor

Thanks for replying, Melinda.  My analysis needs to separate the walking time and the transit time on train/bus.  And due to the size of my data, I need to use Python command to do the Network Analysis instead of clicking on buttons on the menu. 

When I tested the menu options (so that I can create my arcPy commend accordingly), I found that the output route file only provides values for "Total_PublicTransitTime" if I choose "Mode: Public trasnit time " in the "Travel Settings" banner in the Network Analysis.  The output column "Total_walktime" will be "null". However, if I clicked on the blue

sum sign and check both "PublicTransitTime" and "WalkTime", the output file will give me the walk time I need. Is there anyway to include this option into the python command?  

0 Kudos
MelindaMorang
Esri Regular Contributor

When you create your Route layer in python, use the accumulate_attributes parameter to accumulate the WalkTime attribute.  Make Route Analysis Layer—ArcGIS Pro | ArcGIS Desktop 

Keep in mind that the Total_PublicTransitTime will include the walking time, so to get the transit+wait time, subtract off the Total_WalkTime.

jianhedu
New Contributor

Thanks!

0 Kudos
jianhedu
New Contributor

Is there a way to generate values for "wait time", "walk time" and "transit time" separately? 

0 Kudos
MelindaMorang
Esri Regular Contributor

No, there is not currently a way to separate the wait time from the transit time.

0 Kudos
MarcusB9999
New Contributor

I'm sorry to revive this thread but I had a question about public transit tutorial. For my closest facility solver, all of the values of total_walktime are null, when total_publictransittime has non-null values. Does total_publictransittime include the walk time? Or is the fact that the total_walktime is null means that it did not correctly calculate and incorporate walk time? Thank you

0 Kudos
MelindaMorang
Esri Regular Contributor

Assuming you have configured your PublicTransitTime cost attribute according to our tutorials and/or used our network dataset template, then solving using this cost attribute works as follows: the travel time along public transit edges in the network uses the transit schedules and models riding transit, and the travel time along street edges in the network uses walking time along those streets.  So, solving using PublicTransitTime is a complete solution to model a traveler who can take transit but must walk along streets to get from their initial location to transit stop, make transfers between stops, and get from the final transit stop to their destination.  You don't need to add anything else to the analysis to make it correctly model walking when not using transit.

The WalkTime cost attribute is a completely separate cost attribute that is configured in our template primarily to support accumulation.  If you set this as an Accumulate Attribute, it will tell you how much travel time was walking because it returns the walk time value along streets and returns 0 for transit lines.  You can read about Accumulate Attributes in this documentation page for closest facility layers (it's a long page, so search for "Accumulate Cost Attributes".)

0 Kudos
MarcusB9999
New Contributor

Thank you so much!

0 Kudos