找到的节点离我的经纬度坐标 (osmnx) 太远

Node found is too far from my lat, lon coordinates (osmnx)

我的问题是:我有一个地方的地理坐标,但是当我使用ox.get_nearest_node()时,我得到的节点离坐标太远,我不知道为什么:

import networkx as nx
import matplotlib.pyplot as plt
import osmnx as ox
import geopandas as gpd
ox.config(log_console=True, use_cache=True)


place = 'Portugal, Lisbon'
G = ox.graph_from_place(place, network_type='drive')
G = ox.project_graph(G)
hospitals = ox.pois_from_place(place, amenities=['hospital'])

coord_1 = (38.69950, -9.18767)  
target_1 = ox.get_nearest_node(G, coord_1)
print(target_1)

nc = ['r' if node==target_1 else 'gray' for node in G.nodes()]
ns = [50 if node==target_1 else 1 for node in G.nodes()]
fig, ax = ox.plot_graph(G, node_size=ns, node_color=nc, node_zorder=2)

由此我得到以下节点:4751061000

情节是:

而且医院靠海:

看来您的困惑是由于投影问题造成的。我运行 你的代码没有下面一行,它是将 G 投影到 UTM https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.projection.project_graph,你想要的医院被返回。

G = ox.project_graph(G)