2

Trying to do a simple isochrone using the osrm package in R, following this example: https://rstudio-pubs-static.s3.amazonaws.com/259089_2f5213f21003443994b28aab0a54cfd6.html

iso1 <- osrm::osrmIsochrone(loc=c(-93.2223, 44.8848),breaks=10)

Yields the following output to the console. This occurs whether I try to call the default server https://routing.openstreetmap.de/ or an internal OSRM server. I assume this is a simple problem, but I haven't seen anything on Google or 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" ```

Ralph Asher
  • 192
  • 9

2 Answers2

2

The first error may be related to a limit in the OSRM server configuration that your query exceeds, see osrm-routed options, e.g.:

--max-table-size arg (=100)           Max. locations supported in distance
                                        table query

Indeed, computing isochrones may require queries for large time/distance tables.

user43513
  • 135
  • 1
  • 3
1

I see maybe 2 problems :

  • The CRAN version of osrm uses .onAttach() to set the server address and the routing profile. Using osrm:: does not attach the package, so the server is not set. You should use library(osrm) to set the server or directly use osrm.server and osrm.profile arguments in the function.

  • But if you tried to use an internal OSRM server you have probably used something like:

    options(osrm.server = "https://routing.openstreetmap.de/", osrm.profile = "car")
    

    In this case, check the osrm.profile argument, in the previous versions "driving" was allowed as profile name but now the only allowed names are "car", "foot" and "bike".

rcarto
  • 71
  • 2
  • I had attached via `library(osrm)`, forgot to put that in the snippet. I verified both profile and server were as you listed. Same issue. – Ralph Asher Jan 21 '21 at 15:35
  • Well that's unfortunate. I would suggest to try the dev version of `osrm` (`remotes::install_github("riatelab/osrm")`. If this does not work maybe we should continue this discussion in the [github repo issue tracker](https://github.com/riatelab/osrm/issues) as it could be a bug in the package. – rcarto Jan 22 '21 at 08:25
  • My mistake - it works when using my personal Windows machine connecting to https://routing.openstreetmap.de, so probably more a company internal issue. – Ralph Asher Jan 23 '21 at 15:41