0

The code below was shared in the stplanr documentation : stplanr documentation

library(stplanr)
    library(osrm)
    trip <- route(
      from = c(-0.11, 51.514),
      to = c(-0.10, 51.506),
      route_fun = osrmRoute,
      returnclass = "sf"
      )

The above code has from and to nodes in it. Is it possible to find a route with more than 2 points (meaning intermediate stops) ? Please help me find this solution. Solutions apart from stplanr package is also welcome.

I have a set of lat long points as shown below:

points <-tribble (
  ~x,~y, ~order,
  78.14358, 9.921388,1,         
78.14519,   9.921123,2,         
78.14889,   9.916954,3,         
78.14932,   9.912807,4,         
78.14346,   9.913828,5,         
78.13490,   9.916551,6,         
78.12904,   9.918782,7  
)

I want an output like this :

Expected output

Thanks a lot.

Betel
  • 151
  • 7
  • one way to go would be using google api (which you can query from R) - though you to register for it and depending on the quantitiy of routes you need even pay something. Here is a example for two points (in case of routes you have multiple sequences of two points): https://stackoverflow.com/questions/16863018/getting-driving-distance-between-two-points-lat-lon-using-r-and-google-map-ap/31902396#31902396 – DPH Mar 07 '21 at 13:46
  • This question is solved by Andrea in this post : https://stackoverflow.com/questions/66513615/creating-a-route-from-a-list-of-points-and-overlaying-the-route-list-of-points/66521585#66521585 – Betel Mar 08 '21 at 13:51

0 Answers0