Python 找到的节点距离我的lat、lon坐标(osmnx)太远

Python 找到的节点距离我的lat、lon坐标(osmnx)太远,python,networkx,osmnx,Python,Networkx,Osmnx,我的问题是:我有一个地方的地理坐标,但当我使用ox.get_nearest_节点时,我得到的节点离坐标太远,我不知道为什么: 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

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

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,然后返回您想要的医院

G = ox.project_graph(G)

打印出coord_1、target_1和target_1节点的任何可能的详细信息如何?此外,您还可以在coord_1处添加虚拟节点,并在同一绘图上以绿色绘制它,以确保安全。由于在绘图和地图上看到的位置不同,如果有两个同名医院呢?这就是为什么试着打印出更多关于target的信息,谢谢!!原来我把投影坐标和非投影坐标混在一起了。感谢您的反馈!