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_nodes : pandas.DataFrame
transit_edges : pandas.DataFrame
net_connector_edges : pandas.DataFrame
osm_nodes : pandas.DataFrame
osm_edges : pandas.DataFrame
net_nodes : pandas.DataFrame
net_edges : pandas.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_dfs : object

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

timerange : list

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_lookup : dict, 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_int : bool, 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_int : bool, 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_gtfs : bool, optional

if true, all processed gtfs DataFrames will be stored to disk in a hdf5 file

save_dir : str, optional

directory to save the hdf5 file

save_filename : str, optional

name to save the hdf5 file as

Returns:
ua_network : object
ua_network.transit_edges : pandas.DataFrame
ua_network.transit_nodes : pandas.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_edges : pandas.DataFrame

osm edge dataframe

osm_nodes : pandas.DataFrame

osm node dataframe

travel_speed_mph : int, 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_type : str, 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_network : object

urbanaccess_network object with osm_edges and osm_nodes dataframes

ua_network.osm_edges : pandas.DataFrame
ua_network.osm_nodes : pandas.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_network : object

ua_network object with transit_edges, transit_nodes, osm_edges, osm_nodes

headways : bool, 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_df : object, 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_network : object
urbanaccess_network.transit_edges : pandas.DataFrame
urbanaccess_network.transit_nodes : pandas.DataFrame
urbanaccess_network.osm_edges : pandas.DataFrame
urbanaccess_network.osm_nodes : pandas.DataFrame
urbanaccess_network.net_connector_edges : pandas.DataFrame
urbanaccess_network.net_edges : pandas.DataFrame
urbanaccess_network.net_nodes : pandas.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_network : object

urbanaccess_network object with net_edges and net_nodes DataFrames

filename : string

name of the hdf5 file to save with .h5 extension

dir : string, optional

directory to save hdf5 file

overwrite_key : bool, optional

if true any existing table with the specified key name will be overwritten

overwrite_hdf5 : bool, 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:
dir : string, optional

directory to read hdf5 file

filename : string

name of the hdf5 file to read with .h5 extension

Returns:
ua_network : object

urbanaccess_network object with net_edges and net_nodes DataFrames

ua_network.net_edges : object
ua_network.net_nodes : object