Doubt regarding the osrm package in R

Hello, I have some doubts about the use of the osrm package in R for my problem. Just for clarification I have two shapefile files, the first is the "point_project" containing 15 points, and the "highways_state" containing the state highways. Points are properties located in this mentioned state.

The code used is working perfectly, but I would like some more features. Below is the code:

library(sf)
library(osrm)

shp<-read_sf("point_project.shp")
shp<-st_transform(shp,4326) #
dm<-osrmTable(shp)
dm$durations#time matrix
       1     2     3     4     5     6     7     8     9    10    11    12
1    0.0   9.3  50.5 174.4   9.7  23.4  15.6 183.7 240.6  13.6  24.3 103.2
2    9.7   0.0  45.8 169.7  10.6  30.2  22.4 179.0 235.9  20.4  19.6 110.0
3   50.8  49.6   0.0 204.1  51.6  71.2  63.4 213.4 270.3  61.4  31.5 151.0
4  176.6 175.5 206.4   0.0 177.5 197.1 189.3 213.0 105.0 187.3 180.2 276.9
5    9.4   9.1  50.3 174.2   0.0  29.1  21.3 183.5 240.4  19.3  24.1 108.9
6   21.1  23.6  64.9 188.7  24.0   0.0   7.8 185.8 254.9  16.5  38.7  98.9
7   15.9  18.4  59.7 183.5  18.8   7.8   0.0 187.8 249.8  11.3  33.5 100.9
8  173.9 172.7 203.7 188.0 174.7 180.3 179.4   0.0 254.2 183.7 177.4 210.1
9  235.7 234.5 265.4  99.6 236.5 256.1 248.3 272.0   0.0 246.3 239.2 335.9
10  15.6  18.2  59.4 183.3  18.6  18.5  10.8 185.2 249.5   0.0  33.2  98.4
11  25.3  24.1  32.2 178.6  26.1  45.7  37.9 187.9 244.9  35.9   0.0 125.5
12 102.4 104.9 146.2 270.0 105.3  94.4  93.5 209.6 336.2  97.8 120.0   0.0
13  11.1  13.6  54.9 178.8  14.1  21.5  13.7 188.1 245.0   9.0  28.7 101.3
14  19.4  18.2  49.1 161.4  20.2  39.8  32.0 170.7 227.6  30.0  22.9 119.6
15  26.0  28.5  69.8 193.6  28.9  36.6  28.8 203.3 259.8  26.8  43.6 116.4
      13    14    15
1    9.2  30.2  20.9
2   16.0  25.6  27.7
3   57.0  54.2  68.7
4  182.9 163.9 194.6
5   14.9  30.1  26.6
6   18.3  44.6  29.6
7   13.1  39.4  24.4
8  180.2 161.1 191.8
9  241.9 222.9 253.6
10   9.1  39.1  24.6
11  31.6  27.7  43.2
12  99.6 125.9 110.9
13   0.0  34.6  18.9
14  25.7   0.0  37.3
15  22.4  49.5   0.0

#shortest path between point 8 and point 15
dr <-osrmRoute (shp [8,], shp [15,], returnclass = "sf")
plot (st_geometry (dr))

#durations and distance from point 8 to point 15
route <- osrmRoute (src = shp [8,], dst = shp [15,], overview = FALSE)
route
*duration distance 
  191.85   197.63* 

#durations and distance from point 15 to point 8
route <- osrmRoute (src = shp [15,], dst = shp [8,], overview = FALSE)
route
*duration distance 
  203.26   186.82* 

Questions:

1- How do I plot the graph of two or more paths, for example I did the test from point 8 to point 15 (code above). Can I use this same graph to do point 9 to 15 as well?

2- The "dm$durations" code shows the values ​​correspond to the time in minutes from one point to another, as you can see in the "dm $ durations" function. But why are the values ​​not the symmetrical, since they are the same points?

from 8 to 15 is 191.8

from 15 to 8 is 203.3

3-The distances between the same points gave different. In the code above I did from point 8 to point 15, and from point 15 to point 8. But notice that there was a difference in distance. But the distances didn't have to be the same, if they are the same points ???

4- I would like to plot the graph of the shortest path on the highways map. It's possible? that is, unite the two shapefiles.

5 - I am testing the osrm package with a file with few points to better understand how the package works, however in the project I'm working on I will probably have a shapefile file with more than 4000 points. So, you think it will probably work?

Thank you so much!

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