我想在Python中获取两点之间的驾车路程。不允许使用Google Maps API。是否有任何开源API可以帮助计算两个点之间的驾车路程?如果是,一个小的Python示例将是惊人的。提前致谢。
我想在Python中获取两点之间的驾车路程。不允许使用Google Maps API。是否有任何开源API可以帮助计算两个点之间的驾车路程?如果是,一个小的Python示例将是惊人的。提前致谢。
Python包OSMNX中的示例:
示例文档 -> 路由
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
请注意以下摘录:
'如果您正在使用pip安装OSMnx,请先安装geopandas和rtree。最简单的方法是使用conda-forge来安装这些依赖项。'
G = ox.graph_from_place("ADDRESS", network_type="drive")
。 - mallet