User reference¶
User reference for the bikeability package.
This guide covers usage of all public modules and functions within the bikeability package.
bikeability.bikeability module¶
- bikeability.bikeability.calc_bikeability(id_column: str, agg_table: geopandas.GeoDataFrame, download: bool = True, verbose: int = 0, network_gdf: geopandas.GeoDataFrame = None, store_tmp_files: bool = False, date: str = None) geopandas.GeoDataFrame[source]¶
- Parameters:
id_column (str) – unique id column
agg_table (geopandas.GeoDataFrame) – Aggregation geometries to use. Should be a GeoDataFrame with polygon geometries.
download (bool) – if True, download all data from OSM. If False, use stored data in settings.temp_folder
verbose (integer) – verbose
network_gdf (geopandas.GeoDataFrame, optional) – use given network for calculation
store_tmp_files (bool) – store pre- products for debugging. data sets will be written in settings.temp_folder
date (str, optional) – date for which the bikeability index should be calculated
- Returns:
calculated bikeability values for the given aggregation units
- bikeability.bikeability.cycle_tracks_per_agg_unit(aggregation_units: geopandas.GeoDataFrame, network: geopandas.GeoDataFrame) geopandas.GeoDataFrame[source]¶
Intersects cycle tracks with aggregation units
- Parameters:
aggregation_units – Given aggregation units
network – network data set
- Returns:
cycle tracks per aggreation unit
- bikeability.bikeability.cycling_network(network: geopandas.GeoDataFrame)[source]¶
Extracts cycling network from osm street network
- Returns:
cycling network
- bikeability.bikeability.main_street_buffer(network)[source]¶
Generates 15m buffer of main streets
- Returns:
buffer of main streets (15 m)
- bikeability.bikeability.main_streets(network: geopandas.GeoDataFrame)[source]¶
Extracts main street network from osm street network
- Returns:
main street network
- Parameters:
network – Street network of the specified region
aggregation_units – Geometries to aggregate the Index
store_tmp_files – if True: store all kinds of pre-products to settings.tmp_directory
- Returns:
Geodataframe with share of cycling infrastructure on main streets
- Parameters:
network – street network
aggregation_units – geometries to aggregate
store_tmp_files – if True: store all kinds of data into settings.tmp_directory
- Returns:
Geodataframe including share of small streets in the area
bikeability.osm module¶
- bikeability.osm.get_geometries(polygon, tags, verbose=1, date=None)[source]¶
Download geometries from osm via osmnx.
- Parameters:
polygon (Geopandas.GeoDataFrame::POLYGON) – boundary of the area from which to download the data stets (in WGS84)
tags – osm tags to download (example: {‘landuse’: [‘grass’, ‘scrub’, ‘wood’,], ‘natural’: [‘scrub’, ‘wood’, ‘grassland’, ‘protected_area’], ‘leisure’: [‘park’]}
verbose – degree of verbosity. the higher, the more.
date – date: date, on which to download the data
- Returns:
OSM geometries
- bikeability.osm.get_network(polygon: geopandas.GeoDataFrame, network_type: str = 'walk', custom_filter: str = None, simplify: bool = True, verbose: int = 0, date: str = None) geopandas.GeoDataFrame[source]¶
Download street network from osm via osmnx.
- Parameters:
date – date, on which to download the data
simplify – simplify network
polygon (Geopandas.GeoDataFrame::POLYGON) – boundary of the area from which to download the network (in WGS84)
network_type (str) – can be “all_private”, “all”, “bike”, “drive”, “drive_service”, “walk” (see osmnx for description)
custom_filter (str) – filter network (see osmnx for description)
verbose (int) – Degree of verbosity (the higher, the more)
- Returns:
OSM street network
bikeability.grid module¶
- bikeability.grid.create_h3_grid(gdf: geopandas.GeoDataFrame, res: int)[source]¶
- Parameters:
gdf – Geometries to use. Should be a GeoDataFrame with polygon geometries.
res (integer) – resolution of h3 grid (0-15. see https://h3geo.org/docs/core-library/restable)
- Returns:
3h grid for respective region in given resolution
bikeability.util module¶
- bikeability.util.cluster_intersections_to_crossroad(nodes: geopandas.GeoDataFrame, verbose: int = 0) geopandas.GeoDataFrame[source]¶
Clusters nodes of the street network into real crossroads :param nodes: nodes of the street network :param verbose: degree of verbosity :return: Geodataframe including real crossroads as Points
- bikeability.util.get_centroids(cluster: object) tuple[source]¶
- Parameters:
cluster – Point cluster
- Returns:
- bikeability.util.log(message, level=None, name=None, filename=None)[source]¶
Write a message to the logger.
This logs to file and/or prints to the console (terminal), depending on the current configuration of settings.log_file and settings.log_console.
- Parameters:
message (string) – the message to log
level (int) – one of Python’s logger.level constants
name (string) – name of the logger
filename (string) – name of the log file, without file extension
- Return type:
None
- bikeability.util.project_gdf(gdf: geopandas.GeoDataFrame, geom_col: str = 'geometry', to_crs: str = None, to_latlong: bool = False) geopandas.GeoDataFrame[source]¶
Project a GeoDataFrame to the UTM zone appropriate for its geometries’ centroid.
The simple calculation in this function works well for most latitudes, but won’t work for some far northern locations like Svalbard and parts of far northern Norway.
- Parameters:
geom_col – geometry column of the dataset
gdf (Geopandas.GeoDataFrame) – the gdf to be projected
to_crs (int) – CRS code. if not None,project GeodataFrame to CRS
to_latlong (bool) – If True, projects to latlong instead of to UTM
- Return projected_gdf:
A projected GeoDataFrame
- Rtype projected_gdf:
Geopandas.GeoDataFrame
- bikeability.util.ts(style='datetime', template=None)[source]¶
Return current local timestamp as a string.
- Parameters:
style (string {"datetime", "date", "time"}) – format the timestamp with this built-in style
template (string) – if not None, format the timestamp with this format string instead of one of the built-in styles
- Returns:
ts – local timestamp string
- Return type:
string