Create an Integrated Transit and Street Network¶
After loading the transit and street network data, UrbanAccess has tools to compute a travel time weighted graph network of nodes and edges for use with Pandana network accessibility queries.
The Network Data Object¶
The network data object stores the individual transit and street network node and edge components as well as the final integrated network in Pandas dataframes.
-
urbanaccess.network.
ua_network
¶ A urbanaccess object of Pandas DataFrames representing the components of a graph network
- Parameters
- transit_nodespandas.DataFrame
- transit_edgespandas.DataFrame
- net_connector_edgespandas.DataFrame
- osm_nodespandas.DataFrame
- osm_edgespandas.DataFrame
- net_nodespandas.DataFrame
- net_edgespandas.DataFrame
Creating a transit network¶
Create a transit network from the loaded GTFS feeds with travel time impedance.
-
urbanaccess.gtfs.network.
create_transit_net
(gtfsfeeds_dfs, day, timerange, calendar_dates_lookup=None, overwrite_existing_stop_times_int=False, use_existing_stop_times_int=False, save_processed_gtfs=False, save_dir='data', save_filename=None)¶ Create a travel time weight network graph in units of minutes from GTFS data
- Parameters
- gtfsfeeds_dfsobject
gtfsfeeds_dfs object with DataFrames of stops, routes, trips, stop_times, calendar, calendar_dates (optional) and stop_times_int (optional)
- day{‘friday’, ‘monday’, ‘saturday’, ‘sunday’, ‘thursday’, ‘tuesday’,
- ‘wednesday’}
day of the week to extract transit schedule from that corresponds to the day in the GTFS calendar
- timerangelist
time range to extract transit schedule from in a list with time 1 and time 2. it is suggested the time range specified is large enough to allow for travel from one end of the transit network to the other but small enough to represent a relevant travel time period such as a 3 hour window for the AM Peak period. Must follow format of a 24 hour clock for example: 08:00:00 or 17:00:00
- calendar_dates_lookupdict, optional
dictionary of the lookup column (key) as a string and corresponding string (value) as string or list of strings to use to subset trips using the calendar_dates DataFrame. Search will be exact. If none, then the calendar_dates DataFrame will not be used to select trips that are not in the calendar DataFrame. Note search will select all records that meet each key value pair criteria. Example: {‘schedule_type’ : ‘WD’} or {‘schedule_type’ : [‘WD’, ‘SU’]}
- overwrite_existing_stop_times_intbool, optional
if true, and if there is an existing stop_times_int DataFrame stored in the gtfsfeeds_dfs object it will be overwritten
- use_existing_stop_times_intbool, optional
if true, and if there is an existing stop_times_int DataFrame for the same time period stored in the gtfsfeeds_dfs object it will be used instead of re-calculated
- save_processed_gtfsbool, optional
if true, all processed GTFS DataFrames will be stored to disk in a hdf5 file
- save_dirstr, optional
directory to save the hdf5 file
- save_filenamestr, optional
name to save the hdf5 file as
- Returns
- ua_networkobject
- ua_network.transit_edgespandas.DataFrame
- ua_network.transit_nodespandas.DataFrame
Creating a street network¶
Create a street network from the loaded OSM data with travel time impedance.
-
urbanaccess.osm.network.
create_osm_net
(osm_edges, osm_nodes, travel_speed_mph=3, network_type='walk')¶ Create a travel time weight network graph in units of minutes from openstreetmap nodes and edges
- Parameters
- osm_edgespandas.DataFrame
osm edge dataframe
- osm_nodespandas.DataFrame
osm node dataframe
- travel_speed_mphint, optional
travel speed to use to calculate travel time across a distance on a edge. units are in miles per hour (MPH) for pedestrian travel this is assumed to be 3 MPH
- network_typestr, optional
default is ‘walk’ for the osm pedestrian network. this string is used to label the osm network once it is integrated with the transit network
- Returns
- ua_networkobject
urbanaccess_network object with osm_edges and osm_nodes dataframes
- ua_network.osm_edgespandas.DataFrame
- ua_network.osm_nodespandas.DataFrame
Network Integration¶
Create an integrated transit and street network.
If using headways in your integrated network you must first compute the route-stop level headway in this step here.
-
urbanaccess.network.
integrate_network
(urbanaccess_network, headways=False, urbanaccess_gtfsfeeds_df=None, headway_statistic='mean')¶ Create an integrated network comprised of transit and OSM nodes and edges by connecting the transit network with the osm network. travel time is in units of minutes
- Parameters
- urbanaccess_networkobject
ua_network object with transit_edges, transit_nodes, osm_edges, osm_nodes
- headwaysbool, optional
if true, route stop level headways calculated in a previous step will be applied to the osm to transit connector edge travel time weights as an approximate measure of average passenger transit stop waiting time.
- urbanaccess_gtfsfeeds_dfobject, optional
required if headways is true; the gtfsfeeds_dfs object that holds the corresponding headways and stops DataFrames
- headway_statistic{‘mean’, ‘std’, ‘min’, ‘max’}, optional
required if headways is true; route stop headway statistic to apply to the osm to transit connector edges: mean, std, min, max. Default is mean.
- Returns
- urbanaccess_networkobject
- urbanaccess_network.transit_edgespandas.DataFrame
- urbanaccess_network.transit_nodespandas.DataFrame
- urbanaccess_network.osm_edgespandas.DataFrame
- urbanaccess_network.osm_nodespandas.DataFrame
- urbanaccess_network.net_connector_edgespandas.DataFrame
- urbanaccess_network.net_edgespandas.DataFrame
- urbanaccess_network.net_nodespandas.DataFrame
Save Network¶
-
urbanaccess.network.
save_network
(urbanaccess_network, filename, dir='data', overwrite_key=False, overwrite_hdf5=False)¶ Write a urbanaccess_network integrated nodes and edges to a node and edge table in a hdf5 file
- Parameters
- urbanaccess_networkobject
urbanaccess_network object with net_edges and net_nodes DataFrames
- filenamestring
name of the hdf5 file to save with .h5 extension
- dirstring, optional
directory to save hdf5 file
- overwrite_keybool, optional
if true any existing table with the specified key name will be overwritten
- overwrite_hdf5bool, optional
if true any existing hdf5 file with the specified name in the specified directory will be overwritten
- Returns
- None
Load Network¶
-
urbanaccess.network.
load_network
(dir='data', filename=None)¶ Read an integrated network node and edge data from a hdf5 file to a urbanaccess_network object
- Parameters
- dirstring, optional
directory to read hdf5 file
- filenamestring
name of the hdf5 file to read with .h5 extension
- Returns
- ua_networkobject
urbanaccess_network object with net_edges and net_nodes DataFrames
- ua_network.net_edgesobject
- ua_network.net_nodesobject