我想获取python中两点之间的行驶距离。我不允许使用Google Maps API。是否有任何开源API可以帮助计算两点之间的行驶距离?如果是,那么一个小例子就是Python将会很棒。提前致谢。
答案 0 :(得分:1)
来自python软件包OSMNX的示例:
example doc->路由
import networkx as nx
import osmnx as ox
# get the nearest network node to each point
orig_node = ox.get_nearest_node(G, (37.828903, -122.245846))
dest_node = ox.get_nearest_node(G, (37.812303, -122.215006))
# how long is our route in meters?
nx.shortest_path_length(G, orig_node, dest_node, weight='length')
有关如何安装的文档:https://osmnx.readthedocs.io/en/stable/#installation
请注意以下摘录:
'如果要点子安装OSMnx,请先安装geopandas和rtree。使用conda-forge来安装这些依赖项是最简单的。'