Bondify / gtfs_functions

Package with useful functions to create geo-spatial visualizations from a GTFS.
MIT License
114 stars 30 forks source link

feed.segments #22

Closed corazzamtt closed 7 months ago

corazzamtt commented 1 year ago

Thank you very much for this package.

I have a issue when using feed.segments. I have a bus line (from trips) with constant route_id but 4 different shape_id, two of them with direction_id = 0, the other two with direction_id=1. The output of feed.segments includes only two of the four shape_id (one with direction_id = 0 and one with direction_id = 1). When using a less recent version (<2.0), with the function cut_gtfs, I am able to obtain all shape_id for each route_id. In that case I am allowed to pass to the cut_gtfs stop_times, stops, and shapes, in the new version I haven't understood if I can force any parameter. Is there anything I can do to force segments to provide outputs for all shape_id, even if route_id and large part of the stops are duplicated?

Thank you very much again,

Matteo Corazza

corazzamtt commented 1 year ago

Found the problem (a problem of mine): taking the default value for busiest_date (True) I was cutting out the two missing shape_id. Setting busiest_date = False solves the problem.

Sorry and thank you,

Matteo

corazzamtt commented 1 year ago

I apologize for writing back on this issue. In fact even if setting busiest_date = False results significantly improve, it still seems that some fields are missing. In fact in the GTFS fixing route_id, from_stop_id, and to_stop_id, there are multiple shape_ids. In the segments output I have only one shape_id. Is there any optional argument to force segments to provide all shape_ids? Thank you

corazzamtt commented 1 year ago

Sorry for posting again, but I am trying to go deeper in my problem. In fact I am reading the gtfs with partridge, making some computations, building a dataframe in which each line contains data relative to the path from one stop to the following stop. I am using partridge since I need to work on specific days and it seems to me that gtfs_functions doesn't allow to specify the required day when opening the gtfs. I then need to compute the distance between two stops, and I really find the approach of segments in gtfs_functions wonderful. What I find is that the output of segments misses few paths in some of the trips if compared with partridge, so that if a trip is made of let's say 35 pieces with 36 stops, segments misses one of these pieces, in general not the first one or the last one. In some cases one of the stops is different respect the partridge case. In general trips generated with partridge are consistent, i.e all expected stops are present in the right order, so it seems to me that there may be a problem in the way I use gtfs_functions or in the way the gtfs is handed by gtfs_functions.

Thank you again,

Matteo

Bondify commented 9 months ago

hi @corazzamtt thanks a lot for the detailed explanation. I think your problems should be solved with the latest version that brings functionality to take into account all the different patterns of a route. Try with feed = Feed(gtfs_path, busiest_date=False, patterns=True)