OSMnx 获取干净交叉节点的经纬度坐标 [英] OSMnx Get Lat Lon Coordinates of Clean Intersection Nodes

查看:203
本文介绍了OSMnx 获取干净交叉节点的经纬度坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using OSMnx to get clean intersections from OpenStreetMaps road network. The intersection nodes are currently in (x,y) coordinates, but I want to plot them using lat lon coordinates.

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

From the example Jupiter notebook, OSMnx Example #14 Clean Intersection Cluster Nodes, I am able to get the street network and call ox.clean_intersections to produce the 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 的交点,看起来像这样:

I get a Panda Geoseries of the intersections, which looks like this:

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

由于干净的交叉点由 rel="nofollow noreferr 集群组成合并的节点,它们不对应任何具有 osm_id(具有经纬度坐标)的特定节点.

Since the clean intersections are comprised of the centroids of clusters of merged nodes, they don't correspond to any particular node with an osm_id (which have lat lon coordinates).

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

How can I convert these (x,y) points to lat lon coordinates?

推荐答案

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

You projected the graph to meters to clean the intersections with a sensible tolerance parameter. Now you just need to project the cleaned intersection centroids back to lat-long:

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

这篇关于OSMnx 获取干净交叉节点的经纬度坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆