Closed arielfuentes closed 2 years ago
I could do a better job of documenting this. To get this to work, the Mapbox API requires that you specify an origin and destination explicitly for your route with source
and destination
. For example:
optimized_route <- mb_optimized_route(to_visit, profile = "driving-traffic", source = "first", destination = "last", roundtrip = FALSE)
I'll push a fix that enforces this when roundtrip = FALSE
. You can then just make sure your origin point is the first in your dataset, and your destination point is your last.
Ah! I got it now. Thank you for your quick response and great job.
Your original code now works!
Awesome! Thanks!
Hello, I've tried to run the mb_optimized_route function setting the roundtrip parameters as False, but it doesn't work. Here the code:
to_visit <- data.frame( X = c(-0.209307, -0.185875, -0.216877, -0.233511, -0.234541), Y = c(5.556019, 5.58031, 5.582528, 5.566771, 5.550209) ) %>% st_as_sf(coords = c("X", "Y"), crs = 4326)
mb_optimized_route(to_visit, roundtrip = FALSE, profile = "driving-traffic")
It does return the following error:
Error in UseMethod("tbl_vars") : no applicable method for 'tbl_vars' applied to an object of class "NULL"