Difference in distance between directions and distance matrix


I am using the distance matrix functionality. I saw that for at least one source-destination combination the distance was much shorter than I expected. Because when I use the directions feature the distance is longer than in the distance matrix. Settings that I used are profile=‘driving-hgv’ and preference=‘fastest’. How is this possible?


Thanks for reaching out!

There are some differences in the algorithms to find the routes by directions and matrix which might indeed occasionally lead to some discrepancies between results from these endpoints. In order to give you a more detailed answer, could you maybe provide some examples queries which illustrate the issue you observe?


Yes offcourse, I want to go from (5.037793,47.317743) to (8.4541090,51.3575890). The distance matrix is showing: 470.28km and the directions is showing: 720.226km

Thank you!

I’ve tried the provided example but couldn’t reproduce the issue. When I query openrouteservice public API using the following R script I get exactly the same distance of 720226.3m for both directions and matrix endpoints.

Maybe the numbers from matrix you are looking at are actually not distance but duration? The latter is the default returned metrics unless specified otherwise, see the docs.


coordinates <- list(c(5.037793,47.317743), c(8.4541090,51.3575890))
profile <- ors_profile("hgv")

result_d <- ors_directions(coordinates, profile)
#> [1] 720226.3

result_m <- ors_matrix(coordinates, profile, sources = 0, destinations = 1, 
                       metrics = "distance")
#>          [,1]
#> [1,] 720226.3

Created on 2022-02-15 by the reprex package (v2.0.1)

1 Like