问题
import osmnx as ox
ox.__version__ # '0.13.0'
I would like to show the bus routes from the Open Street Map for Hannover on a map using OSMNX by retrieving them as ".graph...". E.g.:
G = ox.graph_from_place('Hannover, Germany', retain_all=False, truncate_by_edge=True,
simplify=True, network_type=None, custom_filter='["route"~"bus"]')
# returns EmptyOverpassResponse: There are no data elements in the response JSON
But I guess this only works for OSM Nodes and Ways, not for Relations? (and public transport routes are stored as relations)?
Therefore I use this workaround:
tags = {'route' : 'bus'}
gdfox = ox.pois_from_place('Hannover, Germany', tags)
gdfox.shape # (4022, 988)
gdfox['element_type'].value_counts() # node 2412, way 1610
This works but it is not perfect as there are some gaps in the routes:
Please advice if there is a better way?
来源:https://stackoverflow.com/questions/62067842/open-street-map-using-osmnx-how-to-retrieve-bus-routes