Developer reference

This is the complete developer reference for the FixBikeNet package. If you are looking for an introduction to FixBikeNet, read the Getting started guide.

fixbikenet.fixbikenet

fixbikenet.fixbikenet.fixbikenet(city_name, proj_crs='3857', radius=2500, maxgap=200, penalty={0: 5, 1: 1}, export_data=True, export_file_format='geojson', export_plot=False)[source]

Finds gaps in bicycle networks and returns the 100 that are the most important to fill. Parameters ———- city_name : str

name of the city that the analysis should be performed on

proj_crsstr, default ‘3857’

coordinate reference system that is used to project osm data. Default is ‘3857’ (WGS 84 / Pseudo-Mercator)

radiusint, default 2500

cut-off length for computation of local betweenness centrality, in meters

maxgapint, default 50

maximum distance between node pairs to be considered as a potential gap

penaltydict, default {0:5, 1: 1}

weighing for shortest path calculations, where streets without protected bike infrastructure (pbi) get penalized

export_databool, optional, default True

If set to True, data will be saved to a file. The filename is [slug].gpkg, where slug is a string id made out of city_name

export_file_formatstr, optional, default “geojson”

File format for the data export, relevant if export_data set to True. Default “geojson”, also possible “gpkg”. If exporting as geojson, generates extra files for street network and city boundary. If exporting as gkpg, these are added all in one file as extra layers.

export_plotbool, optional, default False

If set to True, plot will be saved to a file

Returns

gdfgeopandas.geodataframe.GeoDataFrame

ordered geodataframe with the 100 most important gaps to fill

References

[1] Vybornova, A., Cunha, T., Gühnemann, A. and Szell, M. (2023), Automated Detection of Missing Links in Bicycle Networks. Geogr Anal, 55: 239-267. https://doi.org/10.1111/gean.12324

fixbikenet.functions

fixbikenet.functions.bike_infra_mapping_gdf(g, edges_gdf)[source]

add binary edge attribute pbi to edges_gdf

Parameters:
gnetworkx.MultiDiGraph

simplified graph representing the street network, with added binary edge attribute “pbi”

edges_gdf: geopandas.GeoDataFrame

edges representing the street network

Returns:
edges_gdf: geopandas.GeoDataFrame

edges representing the street network with added binary attribute “pbi”

fixbikenet.functions.compute_local_betweenness_centrality(G, nodes_gdf, radius)[source]

computes weighted betweenness centrality for paths within radius

Parameters:
G: networkx.Graph

undirected simple graph representing the street network with weighted edges

nodes_gdf: geopandas.GeoDataFrame

all nodes in street network

radius: int

maximum length of path for betweennessn centrality calculation, set by user

Returns:
ebc: dict

local betweenness centrality values for all edges in network

fixbikenet.functions.create_gdf_with_geoms(df, edges)[source]
Parameters:
df: pandas.DataFrame

Dataframe with path nodes and path edges

edges: geopandas.GeoDataFrame

The street network, in a projected coordinate reference system

Returns:
gdf: geopandas.GeoDataFrame

projected GeoDataFrame with path nodes and path edges and merged geometries

fixbikenet.functions.find_actual_gaps(G, potential_gaps)[source]

determines which potential gaps are actual gaps by finding paths between all contact nodes and only keeping the gaps that have no protected bike infrastructure

Parameters:
G: networkx.Graph

undirected simple graph representing the street network with weighted edges

potential_gaps: list

all unique potential gaps in protected bicycle network

Returns:
found_gaps: list

list of all gaps in protected bicycle network

found_gaps_nsp: list

list of paths in network for all gaps in protected bicycle network

fixbikenet.functions.find_contact_nodes(G)[source]

find nodes that have both edges with protected and without protected bike infrastructure incident on them

Parameters:
G:networkx.Graph

undirected simple graph representing the street network with weighted edges

fixbikenet.functions.find_edges_to_drop(g)[source]

find parallel edges that have different pbi values, list the ones with pbi=0

Parameters:
gnetworkx.MultiDiGraph

simplified graph representing the street network, with added binary edge attribute “pbi”

Returns:
edges_to_drop: list

unique list of edges to drop-> edges where pbi values differ and pbi value=0 gets dropped

fixbikenet.functions.find_potential_gaps(contact_nodes, nodes_gdf, maxgap)[source]

finds potential gaps in protected bicycle network, corresponding to two contact nodes that are within maxgap euclidean distance of each other

Parameters:
contact_nodes: list

list of all nodes that fulfill criteria to be a contact node

nodes_gdf: geopandas.GeoDataFrame

all nodes in street network

maxgap: int

user defined maximal euclidean distance between two contact nodes

Returns:
potential_gaps: list

all unique potential gaps in protected bicycle network

fixbikenet.functions.get_correct_edgetuples(edge_gdf, nodelist)[source]

helper function that maps a node list (output of nx.shortest_paths) to the correct set of edge tuples that can be used for INDEXING THE EDGE GDF

Parameters:
edge_gdf: geopandas.geodataframe.GeoDataFrame

The street network, in a projected coordinate reference system

nodelist: list

A list of nodes that make up source and targets of edges

Returns:
edgelist_final: list

List of edge tuples that can be used for INDEXING THE EDGE GDF

fixbikenet.functions.map_edges_to_bike_infrastructure(g)[source]

map if edges in graph have bike infrastructure as specified in config_osm.yml

Parameters:
g :networkx.MultiDiGraph

simplified graph representing the street network

Returns:
gnetworkx.MultiDiGraph

simplified graph representing the street network, with added binary edge attribute “pbi”

fixbikenet.functions.rank_gaps_by_b(found_gaps_nsp, G, ebc)[source]

calculates b for all gaps

Parameters:
found_gaps_nsp: list

list of paths in network for all gaps in protected bicycle network

G: networkx.Graph

undirected simple graph representing the street network with weighted edges

ebc: dict

local betweenness centrality values for all edges in network

Returns:
Bs: list

list of values of b for all gaps in protected bicycle network

fixbikenet.functions.weigh_edges(G, penalty)[source]

adds weight parameter to all edges in G, which is calculated by multiplying the length of the edge with the corresponding penalty value

Parameters:
G: networkx.Graph

undirected simple graph representing the street network

penalty: dictionary

dictionary of penalty values, dependent on if edge has bike infrastructure or not

Returns:
G: networkx.Graph

undirected simple graph representing the street network with weighted edges