【发布时间】:2021-04-15 23:00:28
【问题描述】:
我想计算目的地列表和起点之间的最短路径。但首先我需要找到离我的目的地最近的节点。我正在从 OSMNX 函数获取一组兴趣点 (geometries_from_place) 的目的地列表。
import osmnx as ox
import geopandas as gpd
import networkx as nx
print(ox.__version__)
ox.config(use_cache=True, log_console=True)
Kinshasa = [ "Kisenso, Mont Amba, 31, Democratic Republic of the Congo",
"N'djili, Tshangu, Democratic Republic of the Congo",
"Kinshasa, Democratic Republic of the Congo"]
G_Kinshasa = ox.graph.graph_from_place(Kinshasa, simplify=True, network_type='drive')
tags2 = {'amenity' : ['hospital','university','social_facility'],
'landuse' : ['retail', 'commercial'],
'shop' : ['water','bakery']}
POIS = ox.geometries_from_place(Kinshasa, tags2, which_result=1)
Nearest_Nodes = ox.get_nearest_nodes(G_Kinshasa, POIS['geometry'][x],POIS[geometry][y])
如何从作为 GeoSeries 的 POIS['geometry'] 对象获取 lats 和 longs 的 tules 列表,以将其传递给上面最后一行代码中的 get_nearest_nodes? 这是 POIS['geometry'] 的输出示例:
Out[10]:
0 POINT (15.34802 -4.39344)
1 POINT (15.34074 -4.41001)
2 POINT (15.34012 -4.40466)
3 POINT (15.34169 -4.40443)
4 POINT (15.35278 -4.40812)
【问题讨论】: