I want to use the osmnx.graph.from_bbox function to assess bicycle infrastructure. However, there are some roads that show the road itself and then the adjacent bike path.
import networkx as nx
import osmnx as ox
import math
ox.config(use_cache=True, log_console=True)
useful_tags_way = ['bus','bridge', 'tunnel', 'oneway', 'lanes','foot', 'ref', 'name',
'highway', 'maxspeed', 'service', 'access', 'area','landuse',
'width','cycle_network', 'est_width', 'junction', 'surface', 'bicycle', 'traffic_sign','oneway:bicycle'
'cycle_barrier', 'cycleway','cycleway:both:lane', 'cycleway:both','smoothness','parking','parking:lane:right','parking:lane:left',
'cycleway:right','cycleway:right:lane','junction','level','class:bicycle', 'tracktype',
'cylceway:left', 'cycleway:left:lane','bicycle:conditional','oneway:bicycle','cycleway:surface', 'bicycle_road',
'cycleway:width','cycleway:lane','hgv','cycleway:left:segregated','cycleway:right:segregated']
ox.utils.config(useful_tags_way=useful_tags_way)
# Mittelpunkt des gewünschten Bereich8s
latitude, longitude = 48.016696, 7.810164 #Path47.985649,7.829814 #Basler47.985293,7.830120
# Konvertieren Sie 500 Meter in Grad
# Ca. 111320 Meter pro Breitengrad
meters_per_lat = 111320
# Ca. 40075000 * cos(latitude) Meter pro Längengrad
meters_per_lon = 40075000 * math.cos(math.radians(latitude)) / 360
# Berechnen der Halbwerte der Breite und Länge in Grad für 500m
delta_lat = 150 / meters_per_lat
delta_lon = 150 / meters_per_lon
# Berechnen der Bounding Box
north = latitude + delta_lat
south = latitude
east = longitude + delta_lon
west = longitude
bbox= (west, south, east, north)
G = ox.graph_from_bbox(north, south, east, west, network_type='bike', simplify=False, retain_all=True, truncate_by_edge=True)
# Konvertieren Sie das Netzwerk in GeoDataFrames
gdf_nodes, gdf_edges = ox.graph_to_gdfs(G)
# Überprüfen Sie die verfügbaren Spalten, um zu sehen, ob 'surface' und 'bicycle' enthalten sind
print(gdf_edges.columns)
# Speichern Sie die Kanten und Knoten als CSV
gdf_edges.to_csv('edges.csv', index=False)
gdf_nodes.to_csv('nodes.csv', index=False)
print("Die Daten wurden als edges.csv und nodes.csv gespeichert.")
G_projected = ox.project_graph(G)
ox.plot_graph(G_projected)
This results in a duplication of the assessment. Can I assign which path belongs to which highway so that they are only included individually in the assessment?
Can I assign which path belongs to which highway so that they are only included individually in the assessment?
Yes that is correct: you are modeling a network that allows cycling. If OSM's road is tagged such that cycling is not forbidden on it, then it appears in your model, as does the explicit bike path. You can filter out roads if you don't want them in the model by passing a
custom_filterargument: https://osmnx.readthedocs.io/en/stable/user-reference.html#osmnx.graph.graph_from_bboxAlso note that you are using some very old deprecated code that is scheduled for removal in a future release of OSMnx.