# Don't understand the result from osrm package

Hi Everybody,

I have a problem with osrmTable from osrm package,

I did an example with 3 data frame (3 latitude/longitude from 3 city in France : Paris, Rennes and Quimper)
dfPQ :
|Id|lon|lat|
|QUIMPER|-4.09111944455|47.9971425162|
|PARIS 01|2.33629344655|48.8626304852|
dfPR :
|Id|lon|lat|
|RENNES|-1.68186449144|48.1119791219|
|PARIS 01|2.33629344655|48.8626304852|
dfPRQ :
|Id|lon|lat|
|RENNES|-1.68186449144|48.1119791219|
|QUIMPER|-4.09111944455|47.9971425162|
|PARIS 01|2.33629344655|48.8626304852|

I used osrmTable :

distPR <- osrmTable(loc = dfPR, measure = 'duration')
distPR\$durations
RENNES PARIS 01
RENNES 0.0 226.5
PARIS 01 226.8 0.0
distPQ <- osrmTable(loc = dfPQ, measure = 'duration')
distPQ\$durations
QUIMPER PARIS 01
QUIMPER 0.0 226.5
PARIS 01 226.8 0.0
distPRQ <- osrmTable(loc = dfPRQ, measure = 'duration')
distPRQ\$durations
RENNES QUIMPER PARIS 01
RENNES 0.0 NA 384
QUIMPER NA 0 NA
PARIS 01 385.4 NA 0

I don’t understand:

• Why distance between Paris and Rennes is the same time than between Paris and Quimper (Because Paris-Rennes is 150 minutes shorter than Paris-Quimper)
• Why I have difference between the first run (Paris-Rennes = 226,8 min) and the third (Paris-Rennes = 385,4 min)
• Why I have difference between the second run (Paris-Quimper = 226,8 min) and the third (Paris-Quimper = NA)
I’m looking for distance by car between 2 cities (with their longitude and latitude)

K.

I think you must have changed the dataframes before running somehow. Maybe restart R.

``````library(osrm)
#> Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
#> Routing: OSRM - http://project-osrm.org/
library(tidyverse)
dfPRQ <- tribble(
~Id, ~lon, ~lat,
"RENNES",-1.68186449144,48.1119791219,
"QUIMPER",-4.09111944455,47.9971425162,
"PARIS 01",2.33629344655,48.8626304852
)

dfPQ <- dfPRQ %>%
filter(Id!="RENNES")
dfPR <- dfPRQ %>%
filter(Id!="QUIMPER")

osrmTable(loc=dfPR, measure="duration")\$durations
#>          RENNES PARIS 01
#> RENNES      0.0    230.4
#> PARIS 01  228.9      0.0
osrmTable(loc=dfPQ, measure="duration")\$durations
#>          QUIMPER PARIS 01
#> QUIMPER      0.0    379.1
#> PARIS 01   378.3      0.0
osrmTable(loc=dfPRQ, measure="duration")\$durations
#>          RENNES QUIMPER PARIS 01
#> RENNES      0.0   157.2    230.4
#> QUIMPER   156.0     0.0    379.1
#> PARIS 01  228.9   378.3      0.0
``````

Created on 2020-12-29 by the reprex package (v0.3.0)

It's works, Thanks for your help

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.