如何获取所选城市的 OSMnx 中所有可行驶或可骑自行车的道路的长度?

How to get the length of all the drivable or bikeable roads in OSMnx for a chosen city?

例如,我正在尝试获取巴黎所有可行驶街道的长度。从文档中,我找到了这段代码来获取所有道路的面积(以平方米为单位)。

我想要得到的是所有这些可行驶道路的长度(以米或公里为单位)。我该怎么做?

# Get the network graph for drivable public streets (but not service roads)
G = ox.graph_from_place('Paris, France', network_type='drive') # for bikes the network_type would be 'bike'
fig, ax = ox.plot_graph(G, node_size=0, bgcolor='k')

# what sized area does our network cover in square meters?
G_proj = ox.project_graph(G)
nodes_proj = ox.graph_to_gdfs(G_proj, edges=False)
graph_area_m = nodes_proj.unary_union.convex_hull.area
graph_area_m

根据文档,基本统计数据显示:

# show some basic stats about the network
ox.basic_stats(G_proj, area=graph_area_m, clean_intersects=True, circuity_dist='euclidean')
# edge_length_total = sum of all edge lengths in the graph, in meters
# edge_length_avg = mean edge length in the graph, in meters
# street_length_total = sum of all edges in the undirected
# street_length_avg = mean edge length in the undirected

street_length_total 是我选择的网络中所有街道的长度吗?

Is street_length_total the length of all the streets in my chosen network?

是的。