User reference

This is the user reference for the LinkBikeNet package. If you are looking for an introduction to LinkBikeNet, read the Getting started guide.

The standard way to import the LinkBikeNet package is via import linkbikenet as lbn. The main linkbikenet() function below is then called via lbn.linkbikenet(), see the Minimum working example.

linkbikenet.linkbikenet

linkbikenet.linkbikenet.linkbikenet(city_query, connection_strategy='largest_to_closest', export_data=True, city_id=None, export_file_format='geojson', import_files={})[source]

Create links between components of bicycle networks in cities. How components are connected depends on the chosen connection strategy.

Parameters:
city_querystr

Search string for the city that the analysis should be performed on. This is the query used to fetch the data from nominatim.

connection_strategystr, default=”largest

Strategy to use for connecting between components. Default is “largest_to_second”, other options are “largest_to_closest” and “closest_components”.

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_query.

city_idNone or str, default None

If set, the slugified city_id is used in the filename of the data export. For example, a city_id “Athens” will slugify into “athens” in filenames. If set to None, the slugified city_query is used in the filename of the data export. It is useful to set a city_id for cities where the city_query is not the city name, for example to set for a city_query “Municipality of Athens” the city_id to “Athens”.

export_file_formatstr, 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.

import_files: dict, default {}

The following key:value entries can be set:

  • ‘city_boundary’None or str, default None

    If not set to None, the study area is selected from the (Multi)Polygon provided in the city_boundary shape or gpkg file, ideally in unprojected latitude-longitude degrees (EPSG:4326), but EPSG:3857 also works.

  • ‘street_network’None or str, default None

    If not set to None, the street network is loaded from this file. Must be a gpkg file in unprojected crs EPSG:4326 with layers nodes and edges, with the structure that an undirected osmnx street network g has after saved via ox.io.save_graph_geopackage(). For example:

    >>> ox.settings.useful_tags_way = ["highway", "cycleway", "cycleway:right", "cycleway:left", "cycleway:both", "cyclestreet"]
    >>> g = ox.graph_from_place("Barcelona", network_type='all_public', simplify=False, retain_all=True)
    >>> g = nx.MultiGraph(ox.convert.to_digraph(g))
    >>> ox.io.save_graph_geopackage(g, "Barcelona_streets.gpkg")
    
  • ‘bike_network’None or str, default None

    If not set to None, the existing bike network is loaded from this file. Must be a gpkg file in unprojected crs EPSG:4326 with layers nodes and edges, with the structure that an undirected osmnx bike network has after saved via ox.io.save_graph_geopackage().

Returns:
linked_componentsgeopandas.GeoDataFrame

Geodataframe with the proposed links, ordered after strategy chosen.

linkbikenet.settings

Global settings for linkbikenet that can be configured by the user.

export_pathdict(str)

Paths to results and plots folders to save data and plots.

import_pathstr

Path to import files (as defined in growbikenet’s import_files parameter).

silentbool, default False

If set to True, suppresses all user feedback. Useful for batch exports.