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

2023-12-10

我正在使用 OSMnx 来获取cleanOpenStreetMaps 道路网络的交叉路口。交集节点当前位于 (x,y) 坐标中,但我想使用经纬度坐标来绘制它们。

从示例 Jupyter 笔记本中,OSMnx 示例 #14 干净交叉集群节点,我能够获取街道网络并拨打电话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])

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

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

由于干净的交叉点由合并节点簇的质心,它们不对应于具有 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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

OSMnx 获取干净交叉点节点的经纬度坐标 的相关文章

随机推荐