如何使用python获取两个地理坐标之间的行驶距离? [英] How to get the driving distance between two geographical coordinates using python?

查看:421
本文介绍了如何使用python获取两个地理坐标之间的行驶距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取python中两点之间的行驶距离.我不允许使用Google Maps API.是否有任何开源API可以帮助计算两点之间的行驶距离?如果是,那么一个小例子就是Python将会很棒.提前致谢.

I want to get the driving distance between two points in python. I am not allowed to use Google Maps API. Are there any open source APIs that help to calculate the driving distance between two points? If yes, a small example is Python will be amazing. Thanks in advance.

推荐答案

python软件包OSMNX中的示例:

Example from the python package 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

Documentation on how to install: https://osmnx.readthedocs.io/en/stable/#installation

请注意以下摘录:

'如果要点点安装OSMnx,请先安装geopandas和rtree.使用conda-forge来安装这些依赖项是最简单的.'

这篇关于如何使用python获取两个地理坐标之间的行驶距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆