Open Street Map using OSMNX: how to retrieve bus routes?

自闭症网瘾萝莉.ら 提交于 2021-02-11 06:11:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!