kuanb / peartree

peartree: A library for converting transit data into a directed graph for sketch network analysis.
MIT License
201 stars 23 forks source link

Load feed as graph issue for reduced GTFS feed #154

Closed M-nes closed 4 years ago

M-nes commented 4 years ago

Hello,

I find myself facing an issue with the use of the G = pt.load_feed_as_graph(feed, start, end) command.

I am working with GTFS feed of the Paris region in France but I am not interested in the totality of the feed. As I only wanted to work on a smallest area, I selected the stop stations that were of interest to me and then extracted -into new GTFS files- the data of the original GTFS files that were linked to these stop stations. I used a script I found here that I modified a bit to fit my GTFS files and to trim them.

However, when I try to load my trimmed feed with G = pt.load_feed_as_graph(feed, start, end) I get the following error:

InsufficientSummaryResults

``` --------------------------------------------------------------------------- InsufficientSummaryResults Traceback (most recent call last) in 3 # Converts feed subset into a directed network mugenerate_plotph 4 ----> 5 G = pt.load_feed_as_graph(feed, start, end) 6 7 end_time = time.time() ~/anaconda3/envs/iox/lib/python3.6/site-packages/peartree/paths.py in load_feed_as_graph(feed, start_time, end_time, name, existing_graph, connection_threshold, walk_speed_kmph, stop_cost_method, fallback_stop_cost, interpolate_times, impute_walk_transfers, use_multiprocessing) 218 interpolate_times, 219 stop_cost_method, --> 220 use_multiprocessing) 221 222 # This is a flag used to check if we need to run any additional steps ~/anaconda3/envs/iox/lib/python3.6/site-packages/peartree/graph.py in generate_summary_graph_elements(feed, target_time_start, target_time_end, fallback_stop_cost, interpolate_times, stop_cost_method, use_multiprocessing) 119 120 # Same sanity checks on the output before we continue --> 121 _verify_outputs(all_edge_costs, all_wait_times) 122 123 summary_edge_costs = generate_summary_edge_costs(all_edge_costs) ~/anaconda3/envs/iox/lib/python3.6/site-packages/peartree/graph.py in _verify_outputs(all_edge_costs, all_wait_times) 208 # Handle if there are no valid edges returned (or wait times) 209 if all_edge_costs is None or len(all_edge_costs) == 0: --> 210 raise InsufficientSummaryResults('The target time frame returned no ' 211 'valid edge costs from feed object.') 212 if all_wait_times is None or len(all_wait_times) == 0: InsufficientSummaryResults: The target time frame returned no valid edge costs from feed object. ```

I don't understand why the error is raised, I think my GTFS files where trimmed properly so I should be able to create a graph with them.

Any help or indications would be greatly appreciated.

yiyange commented 4 years ago

Hi @M-nes, would you mind providing the trimmed version of GTFS? Maybe I can help look into it.

Also what were the start and end time that you were looking at?

M-nes commented 4 years ago

Yes of course you can find them here: trimmed_gtfs_feed.zip

I am interested in rush hours so I focused on the timestep strating from 7:00 am to 9:00 am.

yiyange commented 4 years ago

@M-nes , you may want to define the start and end time in seconds

start = 7*60*60  # 7:00 AM
end = 9*60*60  # 9:00 AM

and here is the resulting graph - does that look right to you? Screen Shot 2019-10-29 at 2 13 26 PM

M-nes commented 4 years ago

Thank you for your answer @yiyange ! But I still have some questions...

station location map

I am not really familiar with graphs in general so I am not sure if this is normal or not. Is there a way to add all of them into the graph?

yiyange commented 4 years ago

@M-nes that probably has something to do with the fact that we were only looking at time from 7 to 9. Any stop that have no services in that time is not included.

Here I ran for 24 hours the number of nodes in the graph is the same as number of stops in the trimmed feed. (Side note: the nodes in the graph should technically be larger than the number of actual physical stops, but that is another issue (https://github.com/kuanb/peartree/issues/144))

Screen Shot 2019-10-29 at 3 27 00 PM

Not particular reason :) It comes handy and I do not know other good network plotting utils.

M-nes commented 4 years ago

@yiyange Oh ok it's nice to know! Would you mind sharing the code you used to import and plot the feed to your graph G? I still get the InsufficientSummaryResults: The target time frame returned no valid edge costs from feed object. error when I try it.

yiyange commented 4 years ago

@M-nes so I had to rename the individual .txt (remove the extra text in the end) in the folder and re-zip. Here is the code -

fpath = 'paris_trimmed_gtfs_feed.zip'
feed = pt.get_representative_feed(fpath)
start = 0*60*60
end = 24*60*60 
G = pt.load_feed_as_graph(feed, start, end)
kuanb commented 4 years ago

Thanks @yiyange !