【问题标题】:OSMnx Get Lat Lon Coordinates of Clean Intersection NodesOSMnx 获取干净交点节点的经纬度坐标
【发布时间】:2018-11-27 13:19:38
【问题描述】:

我正在使用 OSMnx 从 OpenStreetMaps 道路网络中获取 clean 交叉口。相交节点当前位于 (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])

我得到了十字路口的 Panda Geoseries,如下所示:

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) 点转换为经纬度坐标?

【问题讨论】:

    标签: python graph openstreetmap osmnx


    【解决方案1】:

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

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

    【讨论】:

    • osmnx-examples 一样,这“不会改变或与网络拓扑集成”。有没有办法建立一个新的清洁网络......不仅仅是得到一个没有边缘的点列表?
    • 是的,OSMnx 的最新版本已将旧的 clean_intersections 函数替换为新的强大的 consolidate_intersections 函数,该函数可重建已清理的图形。有关详细信息,请参阅the docs。另请参阅related answer
    猜你喜欢
    • 2017-12-03
    • 1970-01-01
    • 2019-12-31
    • 2021-04-15
    • 2018-02-24
    • 2021-12-03
    • 2016-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多