问题描述
尝试使用 R 中的 osrm
包做一个简单的等时线,如下例所示:
https://rstudio-pubs-static.s3.amazonaws.com/259089_2f5213f21003443994b28aab0a54cfd6.html
iso1 <- osrm::osrmIsochrone(loc=c(-93.2223,44.8848),breaks=10)
将以下输出输出到控制台。无论我尝试调用默认服务器 https://routing.openstreetmap.de/ 还是内部 OSRM 服务器,都会发生这种情况。我认为这是一个简单的问题,但我在 Google 或 SO 上没有看到任何内容。
Error in doTryCatch(return(expr),name,parentenv,handler): object 'res' not found {repeat 8 more times}
Error in UseMethod("st_as_sf") :
no applicable method for 'st_as_sf' applied to an object of class "NULL" ```
解决方法
第一个错误可能与您的查询超出的 OSRM 服务器配置限制有关,请参阅 osrm-routed 选项,例如:
--max-table-size arg (=100) Max. locations supported in distance
table query
实际上,计算等时线可能需要查询大型时间/距离表。
,我认为可能有 2 个问题:
-
osrm
的 CRAN 版本使用.onAttach()
来设置服务器地址和路由配置文件。使用osrm::
不会附加包,因此未设置服务器。您应该使用library(osrm)
来设置服务器或直接在函数中使用osrm.server
和osrm.profile
参数。 -
但是如果您尝试使用内部 OSRM 服务器,您可能使用过类似的东西:
options(osrm.server = "https://routing.openstreetmap.de/",osrm.profile = "car")
在这种情况下,请检查
osrm.profile
参数,在以前的版本中,“驾驶”被允许作为配置文件名称,但现在唯一允许的名称是“汽车”、“脚”和“自行车”。