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_spacingmeters, 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 numericroute_typecolumn (default bus).headway_min— headway in minutes over the operating window (first_departure/last_departurecolumns, default 06:00–22:00); or per-period columnsheadway_<name>matched to theperiodsmapping{name: (start, end)}.speed_kmh(default 25) orduration_min— one-way run time.days—daily/weekdays/weekendor 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,bidirandduration.- 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_layermay also be a GeoDataFrame of stop points withstop_id/stop_namecolumns.stops_layer (str, optional) – Layer names for multi-layer sources (GeoPackage);
stops_layermay also be a GeoDataFrame of stop points withstop_id/stop_namecolumns.periods (dict, optional) –
{name: (start, end)}service periods forheadway_<name>columns, times asH: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.pbfextract; when given, each route geometry is routed along the street network through its vertices withsnap_to_network()before becoming the shape (requirestransitio[snap]).network_type (str, default "driving") – pyrosm network type for
snap_to(ignored whensnap_custom_filteris 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. Seesnap_to_network().check (bool, default True) – Passed to
FeedBuilder.save().**budgets –
validate_feedkeyword arguments.
- Returns:
The validation report of the written feed.
- Return type:
dict