python - OSMnx 获取干净交叉点节点的经纬度坐标

标签 python graph openstreetmap osmnx

我正在使用 OSMnx 从 OpenStreetMaps 道路网络获取干净交叉路口。交叉点当前位于 (x,y) 坐标,但我想使用经纬度坐标绘制它们。

从 Jupiter 笔记本示例中,OSMnx Example #14 Clean Intersection Cluster Nodes ,我能够获取街道网络并调用 ox.clean_intersections 来生成干净的交叉路口。

import osmnx as ox, matplotlib.pyplot as plt, numpy as np
ox.config(use_cache=True, log_console=True)
%matplotlib inline

# get a street network and plot it with all edge intersections
address = '2700 Shattuck Ave, Berkeley, CA'
G = ox.graph_from_address(address, network_type='drive', distance=750)
G_proj = ox.project_graph(G)

# clean up the intersections and extract their xy coords
intersections = ox.clean_intersections(G_proj, tolerance=15, dead_ends=False)
 points = np.array([point.xy for point in intersections])

我得到了交叉点的 Pandas 地理系列,如下所示:

0       POINT (564152.437121744 4189596.945341664)
1      POINT (564846.6779513165 4189615.534235776)
2      POINT (564571.2116373706 4189601.780093061)

由于干净的交叉点由 centroids of clusters of merged nodes 组成,它们不对应于具有 osm_id 的任何特定节点(具有经纬度坐标)。

如何将这些 (x,y) 点转换为经纬度坐标?

最佳答案

您将图表投影到米上,以使用合理的公差参数清理交叉点。现在您只需将清理后的交点质心投影回经纬度即可:

import geopandas as gpd
gdf = gpd.GeoDataFrame(geometry=intersections)
gdf.crs = G_proj.graph['crs']
ox.project_gdf(gdf, to_latlong=True)

关于python - OSMnx 获取干净交叉点节点的经纬度坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50913798/

相关文章:

python - 当使用 While 与 True 和返回来访问列表时,“语句似乎没有效果”

python - sklearn 导入错误 : cannot import name stable_cumsum

c++ - 是否可以检查两个二叉树在线性时间内是否同构?

algorithm - 在图的生成树中找到最大比率最小切割

openstreetmap - 高速公路导出的经纬度,例如 US 101 说排列在 N-S 方向

python - 使用随机森林对文本文档进行分类

python - 如何在python中创建cmyk图像

algorithm - 寻找图的偏序的原因

python - 如何使用python获取两个地理坐标之间的行驶距离?

打开街道 map 0/0/0.png 404