R OSRM: Error in doTryCatch(return(expr), name, parentenv, handler): object 'res' not found

Viewed 1819

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" ```

2 Answers

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.

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".

Related