iduedu.get_gtfs_public_transport_graph¶
- iduedu.get_gtfs_public_transport_graph(feed, *, service_date=None, service_period=None, service_dates=None, start_time=None, end_time=None, crs=None, single_departure_wait_min=None, walk_speed_m_per_min=83.33333333333333, feed_id=None)[source]¶
Build a static public-transport
UrbanGraphfrom a local GTFS feed.Boarding weights use the first-iteration half-headway heuristic. Scheduled services use half the mean gap between consecutive departures of the same route pattern at the same stop.
frequencies.txtusesheadway_secs / 120.A gap is a gap between departures of the same day. With
service_datethe graph is that day’s timetable. Without it each pattern-stop gets the average day’s wait: the wait of every service day ofservice_period– or of the feed’s own calendar, at most 366 days from its start – computed on that day’s trips alone, then averaged with every calendar day weighing the same, over the days the pattern-stop runs. Trips running on none of those days are left out. A feed withoutcalendar/calendar_datesis taken as a single day.start_time/end_timebound the departures within each day;Nonemeans unbounded.- Parameters:
feed (
Union[str,Path,GTFSFeed,Sequence[str|Path|GTFSFeed]]) – Directory containing GTFS text files, a GTFS ZIP archive, an already-readiduedu.gtfs.GTFSFeed, or a sequence of any of those. A sequence is merged withiduedu.merge_gtfs_feeds()first, which qualifies identifiers by source; pass the merged feed yourself when you need to control prefixes or fuse stops across feeds.service_date (
date|datetime|str|None) – Optional service date used withcalendar.txtandcalendar_dates.txt. Acceptsdate,YYYY-MM-DDorYYYYMMDD.service_period (
tuple[date|datetime|str,date|datetime|str] |None) – Optional(first, last)dates, both inclusive, to average the waits over instead of the feed’s own calendar (for example a reference week). Cannot be combined withservice_date.service_dates (
Optional[Sequence[date|datetime|str]]) – Optional explicit days to average the waits over, e.g. a reference week plus the own weeks of merged sources not in service then. Every day still holds only its own trips, so days of different years do not mix. Cannot be combined withservice_dateorservice_period.start_time (
time|str|int|float|None) – Inclusive departure-time bound.Nonemeans unbounded.end_time (
time|str|int|float|None) – Exclusive departure-time bound.Nonemeans unbounded.crs (
Any|None) – Projected target CRS. If omitted, a local UTM CRS is estimated.single_departure_wait_min (
float|None) – Explicit wait fallback for a pattern-stop with one scheduled departure. IfNone, its boarding edge is omitted.walk_speed_m_per_min (
float) – Fallback speed for pathways without an explicit traversal time.feed_id (
str|None) – Name of the feed in its route keys (gtfs:<feed_id>:<route_id>:<direction_id>:<hash>). Defaults to the file or directory name of the feed without.zip(the names of merged sources joined by+). Give each feed its own, stable name when keys from several feeds are stored together.
- Return type:
- Returns:
Directed multigraph of type
"public_transport"with aroutestable, one row per pattern (the trips of a route in one direction calling at the same stops) withref,name,fromandto(first and last stop),operator,colour,line_keyandline_name(the GTFS route),gtfs_route_id,direction_id,shape_id,stopsandinterval_min(the mean time between departures at its first stop, twice its boarding wait). Route nodes and edges carry theroute_keyof their pattern; a platform lists the keys of the patterns calling there.