python - 如何获取所选城市的 OSMnx 中所有可驾驶或可骑自行车的道路的长度?
问题描述
例如,我正在尝试获取巴黎所有可行驶街道的长度。从文档中,我找到了这段代码来获取所有道路的面积(以平方米为单位)。
我想要得到的是所有这些可行驶道路的长度,以米或公里为单位。我怎样才能做到这一点?
# 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
我选择的网络中所有街道的长度是多少?
解决方案
street_length_total 是我选择的网络中所有街道的长度吗?
是的。
推荐阅读
- javascript - 如何让 Keynote 演示文稿在 PWA 中显示?
- c++ - 附加到 C++ 中的多态列表?
- python - 如何使用加权最小二乘回归从 statsmodels (python) 中获取差分回归方程
- python - 使用循环有条件地重试脚本
- ubuntu - Certbot 触发 nginx 重复监听
- r - 如何使用 R 代码生成填充特定文本的 R 脚本
- php - 如果在 PHP 中遇到被零除,则返回零值
- r - 我可以从“rtweet”的用户那里获得超过 3200 条推文吗?
- java - ajc和javac生成的类的序列化不兼容
- c++ - 为什么标准库不以无锁方式为 8 字节以下的结构实现 std::atomic?