I am still trying to figure out OSM and OSMnx. I want to count how many roundabouts are there in Paris for example. The problem is that many roundabouts are stored as ways, but in pieces. So, if I count all the tags where junction=roundabout
, I will count some roundabouts more than once.
How can I avoid this and only count each roundabout once?
# 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()))
Both are wrong and I couldn't come up with a right way to do this. Can someone help out?