我仍在试图弄清楚OSM和OSMnx。例如,我想计算一下巴黎有多少个环岛。问题是,许多环形交叉口都是作为通道存储的,但都是零碎的。因此,如果我计算所有junction=roundabout
的标记,我将不止一次地计算一些环形交叉口
# This is what I used to plot all the roundabouts in Paris
roundabouts = ox.graph_from_place('Paris, France', network_type = 'drive',
custom_filter = '["junction"~"roundabout"]', retain_all = True, simplify = False)
fig, ax = ox.plot_graph(roundabouts, node_size=0, bgcolor='k')
# This is what I tried to use to count the roundabouts
# 1st option
edges = ox.graph_to_gdfs(roundabouts, nodes=False, edges=True)
print('Roundabouts count:', edges.junction.count() )
# 2nd option, tried to group by OSM id and then count unique IDs
edges = ox.graph_to_gdfs(roundabouts, nodes=False, edges=True)
print('Roundabouts count:', len(edges[edges['junction']=='roundabout'].groupby('osmid').size()))
两者都是错误的,我想不出一个正确的方法来做这件事。有人能帮忙吗
因为OSM是如何标记这些元素的,所以没有简单直接的方法来实现这一点。这里有两个选项可以对城市中的环岛数量进行类似的估计。这两种方法都会让你走上正确的道路,但还需要进一步的实验
前者只对城市中的环形交叉口进行建模,然后查找所有弱连通图组件。每个离散组件都被视为唯一的环形交叉口。后者聚集(拓扑合并)交叉点,然后检查哪些交叉点的缓冲区与环行交叉口边缘重叠。另请参见
consolidate_intersections
函数的the docs相关问题 更多 >
编程相关推荐