ropensci / stplanr

Sustainable transport planning with R
https://docs.ropensci.org/stplanr
Other
421 stars 66 forks source link

Feature request: bus info #283

Closed JimShady closed 5 years ago

JimShady commented 5 years ago

Hi Robin,

I was wondering if there is data in the background of the route_transportapi_public that is being discarded, and which could be returned to the user? For instance could the bus numbers / segments be returned within this query?

start    <- c(-0.112327, 51.505747)
end      <- c(-0.137143, 51.515080)

route <- route_transportapi_public(from = start, to = end, modes = 'bus')

route
class       : SpatialLines 
features    : 1 
extent      : -0.13731, -0.11205, 51.50514, 51.51504  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0

Thanks, James

Anyaoha commented 5 years ago

I would also like to ask a question regarding to vehicle routing.

How can I plot vehicle track on a map in R. I have the coordinates of several locations but I would like to plot the track from a destination, touching all other locations and returning to the same origin.

If you have an idea on how to get this done. Kindly reply.

Thanks

Robinlovelace commented 5 years ago

Hi @JimShady and @Anyaoha these are good questions. You can create routes with a variety of route_() functions, that will return spatial data objects. However, as you point-out, these are not feature complete. A bit of history may be useful here: stplanr was originally developed to deliver a web app for contract with the DfT, and only contained the function route_cyclestreets(). Since then things have developed substantially. We have the sf package. And, having learned about the the concept of modularity in software design, have started to split-out packages from stplanr to make it less monolithic.

Three examples of split-out packages are:

There are many packages providing R interfaces to routing services. I suggest taking a look here for more information: https://geocompr.robinlovelace.net/transport.html#routes

It's very useful to have this issue open because it provides a motivation to finish the refactoring work. When it is finished I envision the route() function being a high-level wrapper to a range of routing services, local and remote. Any input into that process very welcome. Thanks, and please let us know how you get on.

JimShady commented 5 years ago

Thanks @Robinlovelace .

Anyaoha commented 5 years ago

Thanks @Robinlovelace I would use this to experiment on plotting tracks for the road network. It is interesting to see a lot of work being done in the routing network domain. Please keep me posted if you find out a code that plots track on road networks touching all coordinates assigned.

JimShady commented 5 years ago

@Anyaoha -- I think you are talking about the 'travelling salesman' routing algorithm. I'm just googling trying to find an implementation of it in R for you but struggling. Do you know of one @mpadge ?

JimShady commented 5 years ago

This looks like what you need @Anyaoha : https://www.r-bloggers.com/travelling-salesman-with-ggmap/

Anyaoha commented 5 years ago

@JimShady no I don't but I would check the @mpadge out. I quickly went through the ropensci/osmplotr I found there but it wasn't helpful. I am glad you're helpful.

Anyaoha commented 5 years ago

@JimShady wow. Thanks I would implement that and see how it goes. My dataset just has about 600 coordinates which I want to see if I can cluster them in pairs and plot routes for each. After which I would have to optimize the original route to find out the shortest route distance of each. I would try out this which you have helped me out with. Anyways my eyes would still be open to receive more help. Thanks a bunch!

Robinlovelace commented 5 years ago

For the specific question, I think what you need is this (or the new transportAPI package listed above, or an OTP-based approach - @mem48 is working on that also): https://github.com/ATFutures/gtfs-router by @mpadge

For the broader question of updating routing capabilities, stplanr could be a useful metapackage to host a range of transport planning tools, some of which use other packages, is my thinking.

Closing this issue for now in any case. Great discussion.

mpadge commented 5 years ago

For completeness: If this is indeed a Q about the travelling saleswoman problem, then yes, there in a R package: TSP.