OSMnx - tags missing in graph edges

早过忘川 提交于 2020-06-16 04:34:18

问题


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

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