【发布时间】:2021-11-24 10:37:17
【问题描述】:
我有以下功能可以在给定位置查找 culdesacs
def find_culdesacs(graph):
"""
Culdesacs are nodes with only one edge connection and which are not on the boundary of the OpenStreetMap.
Parameters
----------
:param graph: object: OGraph object from osm_request
Returns
-------
:return culdesacs: list of node IDs
"""
streets_per_node = graph.G.graph['streets_per_node']
# parse out the data structure provided by OSM
# nodes = streets_per_node.split(',')
# streets_per_node = {node.split(':')[0][1:]: node.split(':')[1][1:].replace('}', '') for node in nodes}
culdesacs = [key for key, value in streets_per_node.items() if int(value) == 1]
return culdesacs
但是,运行代码时出现以下错误:
streets_per_node = graph.G.graph['streets_per_node']
KeyError: 'streets_per_node'
有人能帮忙弄清楚如何解决这个错误吗?
【问题讨论】:
-
您需要提供完整的最小可重现代码 sn-p 以供其他人重现和解决此问题。
标签: python-3.x networkx osmnx