transitio.edit.build_feed

Contents

transitio.edit.build_feed#

transitio.edit.build_feed(source, output, *, timezone, routes_layer=None, stops_layer=None, agency_name='transitio scenario', agency_url='https://github.com/cafein-py/transitio', periods=None, stop_spacing=400.0, stop_snap_distance=100.0, service_start='20260101', service_end='20261231', exact_times=False, snap_to=None, network_type='driving', snap_custom_filter=None, check=True, **budgets)#

Build a frequency-based GTFS feed from geodata route layers.

Reads route alignments (LineStrings) — from a GeoPackage/Shapefile path or a GeoDataFrame — under a small attribute convention, and writes a complete validated feed: geometries become shapes, stops come from an optional point layer (snapped to each route) or are interpolated at stop_spacing meters, and headway attributes become frequency-based trips in both directions.

Route attributes (all optional except a headway):

  • route_id / route_short_name — identifiers (defaulted from the row index when absent).

  • mode — tram/subway/rail/bus/ferry, or a numeric route_type column (default bus).

  • headway_min — headway in minutes over the operating window (first_departure/last_departure columns, default 06:00–22:00); or per-period columns headway_<name> matched to the periods mapping {name: (start, end)}.

  • speed_kmh (default 25) or duration_min — one-way run time.

  • days — daily/weekdays/weekend or comma-separated weekday names (default daily).

  • bidirectional — truthy to also generate the reverse direction (default true).

Shapefile DBF field names cap at 10 characters, so the long columns have short aliases: short_name, headway, first_dep, last_dep, bidir and duration.

Parameters:
  • source (str, pathlib.Path or GeoDataFrame) – Route layer source; paths are read with geopandas.

  • output (str or pathlib.Path) – Feed zip to write.

  • timezone (str) – IANA agency timezone (required by GTFS).

  • routes_layer (str, optional) – Layer names for multi-layer sources (GeoPackage); stops_layer may also be a GeoDataFrame of stop points with stop_id / stop_name columns.

  • stops_layer (str, optional) – Layer names for multi-layer sources (GeoPackage); stops_layer may also be a GeoDataFrame of stop points with stop_id / stop_name columns.

  • periods (dict, optional) – {name: (start, end)} service periods for headway_<name> columns, times as H:MM:SS.

  • stop_spacing (float, default 400) – Interpolated stop spacing in meters when no stop layer is given.

  • stop_snap_distance (float, default 100) – Maximum meters from a route line for a layer stop to serve it.

  • service_start (str, default 2026) – Calendar validity window, YYYYMMDD.

  • service_end (str, default 2026) – Calendar validity window, YYYYMMDD.

  • exact_times (bool, default False) – Expand every frequency window into individually scheduled trips (one per departure) instead of writing frequencies.txt.

  • snap_to (str or pathlib.Path, optional) – OSM .osm.pbf extract; when given, each route geometry is routed along the street network through its vertices with snap_to_network() before becoming the shape (requires transitio[snap]).

  • network_type (str, default "driving") – pyrosm network type for snap_to (ignored when snap_custom_filter is given).

  • snap_custom_filter (dict, optional) – A pyrosm Overpass-style tag filter for snap_to — e.g. {"railway": ["tram"]} to snap alignments to tram rails. See snap_to_network().

  • check (bool, default True) – Passed to FeedBuilder.save().

  • **budgets – validate_feed keyword arguments.

Returns:

The validation report of the written feed.

Return type:

dict