我需要计算栅格质心(长纬度坐标)和参考点之间的旅行时间(例如乘车)。然而,不幸的是,许多栅格质心不在 googlemaps 的覆盖范围内,我想知道是否有一种解决方法可以让我以最快的方式到达参考点(例如结合步行到街道然后开车到参考点),如果是这样,我如何有效地做到这一点?
问题是,当我只是寻找下一个定位点时,我会产生偏差,将到该点的距离作为步行距离,然后从那里到参考点的 googlemaps 行驶距离,因为最近的点可能不是最快路线..
我试图使用 gmapsdistance-function 来做到这一点。下面是一个例子:
library(gmapsdistance)
#While this can be located and works well
> gmapsdistance(origin = "5.600451+-0.202553",
+ destination = "5.591622+-0.187677",
+ mode = "walking")
$Time
[1] 2101
$Distance
[1] 2667
$Status
[1] "OK"
#Changing the origin to other points often does not work as the points cannot be located and results in an NA-output
> gmapsdistance(origin = "7.9254948+-0.6283887",
+ destination = "5.591622+-0.187677",
+ mode = "walking")
$Time
[1] NA
$Distance
[1] NA
$Status
[1] …Run Code Online (Sandbox Code Playgroud)