riatelab / osrm

Interface between R and the OpenStreetMap-based routing service OSRM
https://doi.org/10.21105/joss.04574
GNU General Public License v3.0
233 stars 31 forks source link

The OSRM server returned an error #75

Closed ImLukeSkywalker closed 3 years ago

ImLukeSkywalker commented 3 years ago

Hello! I havent find information about this error, and I'm not sure if it's from OSRM or I need to load another package.

This is my code:

lugar<-read_sf("E:/2021/Ruralidad LA/Panamá/Isocronas/Lugarespoblados.shp")

isochrone <- map2(lugar$LONG, lugar$LAT, ~ osrmIsochrone(loc = c(.x, .y), breaks = seq(0, 120, 30))) %>% do.call(what = rbind)

Start running and I get this error: The OSRM server returned an error: Error in doTryCatch(return(expr), name, parentenv, handler): objeto 'res' no encontrado

I already tried changin server with this: options(osrm.server = "https://routing.openstreetmap.de/", osrm.profile = "car")

Error in UseMethod("st_as_sf") : no applicable method for 'st_as_sf' applied to an object of class "NULL"

But I still failling...

Thanks for your answer.

rCarto commented 3 years ago

Hello, Can you please provide a reproducible example (data and code).

JDFPalladium commented 3 years ago

Hi,

I'm getting the same error. Starting a new session, if I run the example from the project documentation, I get the following:

library(osrm) iso <- osrmIsochrone(loc = c(13.43,52.47), breaks = seq(0,14,2)) The OSRM server returned an error: Error in doTryCatch(return(expr), name, parentenv, handler): object 'res' not found

Thank you

ImLukeSkywalker commented 3 years ago

Hello, Can you please provide a reproducible example (data and code).

Sure, I attach the shapefile that I'm using and the code it's:

lugar<-read_sf("E:/2021/Ruralidad LA/Panamá/Isocronas/Lugarespoblados.shp")

isochrone <- map2(lugar$LONG, lugar$LAT, ~ osrmIsochrone(loc = c(.x, .y), breaks = seq(0, 180, 30))) %>% do.call(what = rbind)

isochrone@data$drive_times <- factor(paste(isochrone@data$min, "a", isochrone@data$max, "Minutos"))

factpal <- colorFactor("Blues", isochrone@data$drive_times, reverse = TRUE)

leaflet() %>% setView(mean(lugar$LONG), mean(lugar$LAT), zoom = 7) %>% addProviderTiles("Stamen.TonerLite") %>% addPolygons(fill = TRUE, stroke = TRUE, color = "black", fillColor = ~factpal(isochrone@data$drive_times), weight = 0.5, fillOpacity = 0.4, data = isochrone, popup = isochrone@data$drive_times, group = "Drive Time") %>% addLegend("bottomright", pal = factpal, values = isochrone@data$drive_time,
title = "Isocronas")

Lugarespoblados.zip

rCarto commented 3 years ago

Hello, this problem is most probably due to changes made to the demo server (decrease max size of table requests). The dev version of OSRM should work now. remotes::install_github("riatelab/osrm")

However, the best solution to avoid this kind of disappointment is to run your own OSRM server. It allows to run faster and unlimited requests.

ImLukeSkywalker commented 3 years ago

Nice its working now! Thank you so much. How can I access to an OSRM server?

rCarto commented 3 years ago

The best way is to run it on your own computer with docker. Links are provided in this repo README (https://github.com/riatelab/osrm#description)