我正在使用OSMnx从OpenStreetMaps道路网络获得干净交叉点。交叉点节点当前处于(x,y)坐标,但我想使用lat lon坐标绘制它们。
从示例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])
我得到了交叉路口的熊猫地质系列,如下所示:
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(具有lat lon坐标)的任何特定节点不对应。
如何将这些(x,y)点转换为lat lon坐标?
答案 0 :(得分:1)
您已将图形投影到仪表,以使用合理的公差参数清洁相交处。现在,您只需要将清洗后的交点质心投影回lat-long:
import geopandas as gpd
gdf = gpd.GeoDataFrame(geometry=intersections)
gdf.crs = G_proj.graph['crs']
ox.project_gdf(gdf, to_latlong=True)