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
237 stars 31 forks source link

osrmTable: biased travel times #62

Closed Moerri closed 4 years ago

Moerri commented 4 years ago

I get quite biased travel times with osrmTable, using both the osrm demo server and my own server (covering Switzerland). The demo example, on the demo server:

data("berlin")
osrmTable(loc=apotheke.sf[1:5,])

results in:

$durations
           440338666 538057637 977657079 3770254015 364363337
440338666        0.0      21.4      34.1       19.5      11.7
538057637       22.8       0.0      42.7       16.1      20.7
977657079       34.1      40.3       0.0       31.2      27.4
3770254015      22.3      15.3      30.7        0.0      12.7
364363337       12.0      20.2      26.8       12.0       0.0

$sources
                lon      lat
440338666  13.43870 52.47730
538057637  13.57896 52.45816
977657079  13.49047 52.61726
3770254015 13.51960 52.49760
364363337  13.45593 52.50109

$destinations
                lon      lat
440338666  13.43870 52.47730
538057637  13.57896 52.45816
977657079  13.49047 52.61726
3770254015 13.51960 52.49760
364363337  13.45593 52.50109

And I use the following two points in Switzerland to test the function osrmTable:

 locations = data.frame(id = c("Schaffhausen",  "Winterthur"),
                                      lat = c(47.696189, 47.510425),
                                      lon = c(8.628507, 8.722746))
osrmTable(loc=locations)

results in:

$durations
             Schaffhausen Winterthur
Schaffhausen          0.0      148.4
Winterthur          148.4        0.0

$sources
                  lon      lat
Schaffhausen 47.68521 8.560717
Winterthur   47.44443 8.769290

$destinations
                  lon      lat
Schaffhausen 47.68521 8.560717
Winterthur   47.44443 8.769290

The actual travel time between these two points (estimated on map.project-osrm.org) would be around 24 minutes. I get the exact same, but wrong results with the demo server and my own server. I use options(osrm.profile = "driving"). On my server, I use the car.lua driving profile (https://github.com/Project-OSRM/osrm-backend/blob/master/profiles/car.lua). I assume the osrm demo server uses the same. I also tried the osrmTable on other coordinates in the Swiss canton of Glarus - these results also do not look plausible. What strikes me are the quite different coordinates of source and destination in the results of osrmTable above, in both examples. But even when using these, I get a travel time of 43 minutes (for the Swiss example), not 148. Can anyone help me on with this issue? My first guesses would be that problems are caused by the car.lua driving profile (I have plotted the result of osrmRoute between Schaffhausen and Winterthur, and it sadly looks like a large, unnecessary detour), and/or by how source and destination are set in the map. Any other guesses?

Thank you in advance!

Moerri commented 4 years ago

I have found the problem ;-) I mixed up long/lat coordinates when downloading the map for the server, as well as when calculating travel times with R... I was therefore moving around in Somalia instead of Switzerland... I will embarrassedly close this issue ;-).