Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple distances with osrmRoute? #18

Closed
Linalalina opened this issue Jan 23, 2017 · 4 comments
Closed

Multiple distances with osrmRoute? #18

Linalalina opened this issue Jan 23, 2017 · 4 comments

Comments

@Linalalina
Copy link

Hello,
I'm a new user of the package and love it so far, thank you!!
I do have a question if I can use osrmRoute to get multiple distances? I have a table of a couple of 100 coordinates from -> to. So a Matrix is out.
Data structure of a is ID, x, y, Long, lat (with x and y being the source coordinates and Long, lat being the Destination coordinates). The function works perfectly with just one row, but as soon as I ask for 2 rows I get an error message

route <- osrmRoute (src = a[1:2, c("id","x","y")],

  •                 dst = a[1:2, c("id","long","lat")], overview="simplified", sp="TRUE")
    

osrmRoute function returns an error:
Error: URL string malformed close to position 32: "23, 13"

since I only Need the distance(and maybe minutes, but not neccessarily), is there a way get those for multiple lines?
Thank you!
Lina

@rCarto
Copy link
Member

rCarto commented Jan 23, 2017

Hello,
osrmRoute (based on the route service of OSRM) cannot compute multiple routes in one call.
You could build a loop that goes through each row of a to store each individual routes in a list.
Or, if you only need the duration (not the distance), you can use the osrmTable function.

@rCarto rCarto closed this as completed Jan 25, 2017
@Linalalina
Copy link
Author

Hi Carto,
thanks, I did program a Loop, had some Problems with the overview Option "simplified" (no method for coercing this S4 class to a vector ), but with "FALSE" it works! Thanks so much!

@rCarto
Copy link
Member

rCarto commented Jan 25, 2017

To overcome the "no method for coercing this S4 class to a vector" warning I think you should start the sp library at the beginning of your script (library(sp)).

@rCarto
Copy link
Member

rCarto commented Nov 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants