问题
I'm trying to detect all the streets in a city were bikes can ride. To do this I want to include the footways that include the tag "bicycle":"yes"
, but I can't find it in the data downloaded with OSMnx.
For example the edge with id 45031879 as an xml downloaded directly from openstreetmap website appears like this:
<way id="45031879" visible="true" version="4" changeset="64616340" timestamp="2018-11-18T10:34:12Z" user="livmilan" uid="712033">
<nd ref="571102337"/>
...
<nd ref="1587102704"/>
<tag k="bicycle" v="yes"/> <=====
<tag k="highway" v="footway"/>
</way>
But in the edges when downloaded with OSMnx with command graph = ox.graph_from_place(place, network_type='all'))
it appears like this:
{'osmid': 45031879, 'highway': 'footway', 'oneway': False, 'length': 22.818, 'geometry': <shapely.geometry.linestring.LineString object at 0x00000170F3F112C8>}
It appears that the bicycle information went lost. Is there a way to download the additional tags with osmnx?
Thank you
回答1:
Configure the useful_tags_way
setting to add additional OSM way tags to retain as graph edge attributes:
import osmnx as ox
ox.config(log_console=True, use_cache=True,
useful_tags_way = ox.settings.useful_tags_way + ['bicycle'])
place = 'Berkeley, CA, USA'
G = ox.graph_from_place(place, network_type='bike')
edges = ox.graph_to_gdfs(G, nodes=False)
'bicycle' in edges.columns #True
来源:https://stackoverflow.com/questions/59841035/osmnx-tags-missing-in-graph-edges