Transportation#
Module for loading and processing GTFS data, constructing transportation networks.
- city2graph.transportation.get_od_pairs(gtfs_data, start_date=None, end_date=None, include_geometry=True, as_generator=False, chunk_size=10000)[source]#
Generate origin-destination pairs with timestamps from GTFS data.
When as_generator is False this function returns a complete (Geo)DataFrame, and when True it returns a generator that yields chunks.
- Parameters:
gtfs_data (dict) – Dictionary with GTFS dataframes from load_gtfs.
start_date (str, optional) – Start date in YYYYMMDD format; if None, defaults from calendar.
end_date (str, optional) – End date in YYYYMMDD format; if None, defaults from calendar.
include_geometry (bool, default True) – Whether to include LineString geometries connecting the stops.
as_generator (bool, default False) – If True, return a generator yielding GeoDataFrame chunks.
chunk_size (int, default 10000) – Number of rows per chunk when using the generator.
- Returns:
If as_generator is False, returns a complete GeoDataFrame (or DataFrame if include_geometry=False). If as_generator is True, returns a generator yielding (Geo)DataFrame chunks.
- Return type:
geopandas.GeoDataFrame or pandas.DataFrame or generator
- city2graph.transportation.load_gtfs(gtfs_zip_path)[source]#
Complete workflow to process a GTFS zip file into DataFrames with geometry columns and summary statistics.
- city2graph.transportation.travel_summary_graph(gtfs_data, start_time=None, end_time=None, calendar_start=None, calendar_end=None, as_gdf=True)[source]#
Create a graph representing travel times and frequencies between stops.
- Parameters:
gtfs_data (dict) – Dictionary with GTFS dataframes from load_gtfs
start_time (str, optional) – Start time of day (HH:MM:SS) to filter trips
end_time (str, optional) – End time of day (HH:MM:SS) to filter trips
calendar_start (str, optional) – Start date in YYYYMMDD format to filter by service calendar
calendar_end (str, optional) – End date in YYYYMMDD format to filter by service calendar
as_gdf (bool, default True) – If True, return a GeoDataFrame; if False, return a dictionary
- Returns:
Network of stop connections with travel times and frequencies
- Return type: