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 UrbanGraph from 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.txt uses headway_secs / 120.

A gap is a gap between departures of the same day. With service_date the graph is that day’s timetable. Without it each pattern-stop gets the average day’s wait: the wait of every service day of service_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 without calendar/calendar_dates is taken as a single day.

start_time/end_time bound the departures within each day; None means unbounded.

Parameters:
  • feed (Union[str, Path, GTFSFeed, Sequence[str | Path | GTFSFeed]]) – Directory containing GTFS text files, a GTFS ZIP archive, an already-read iduedu.gtfs.GTFSFeed, or a sequence of any of those. A sequence is merged with iduedu.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 with calendar.txt and calendar_dates.txt. Accepts date, YYYY-MM-DD or YYYYMMDD.

  • 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 with service_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 with service_date or service_period.

  • start_time (time | str | int | float | None) – Inclusive departure-time bound. None means unbounded.

  • end_time (time | str | int | float | None) – Exclusive departure-time bound. None means 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. If None, 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:

UrbanGraph

Returns:

Directed multigraph of type "public_transport" with a routes table, one row per pattern (the trips of a route in one direction calling at the same stops) with ref, name, from and to (first and last stop), operator, colour, line_key and line_name (the GTFS route), gtfs_route_id, direction_id, shape_id, stops and interval_min (the mean time between departures at its first stop, twice its boarding wait). Route nodes and edges carry the route_key of their pattern; a platform lists the keys of the patterns calling there.