我的目标是获得两个地理位置(纬度和经度)之间的行驶距离/时间,这样做是为了一个大约2k对地理位置的文件。 我必须使用免费API或任何免费资源,这就是我使用openrouteservice的原因,在函数中包含以下简单代码,以获取行驶距离/时间:
import numpy as np
import pandas as pd
import openrouteservice
from openrouteservice import convert
api_key = 'api_key'
client = openrouteservice.Client(key=api_key)
coords = ((lon_orig, lat_orig),(lon_dest, lat_dest))
res = client.directions(coords, radiuses =1000)
res['routes'][0]['summary']
我的问题是由于这个API给出了类型为:'404 ({'error': {'code': 2009, 'message': 'Route could not be found - Unable to find a route between points...'
的错误,因为并非所有的目的地地理位置对都可以通过驾驶或步行到达
举个例子,当我尝试coords = ((-69.20438,-12.58308),(-70.43474,-13.03910))
时,我得到了一个错误,因为那里像一条河,所以汽车无法到达确切的点
因此,我想知道是否有某种方法可以将目的地地理位置近似为某种新的可到达位置(我阅读了openrouteservice文档,但没有找到类似的内容,还试图增加“radius”参数,但我还是出错了),或者可能使用另一个API来帮助openrouteservice改进这一点,或者最后推荐另一种有效的方法
目前没有回答
相关问题 更多 >
编程相关推荐