Closed loanho23 closed 3 years ago
Thanks for your encouraging words, and for engaging with the package. There are a couple of ways to approach your first question.
gtfs_route()
function, and the underlying gtfs_timetable()
function which it calls as a pre-processing step, both have a route_pattern
parameter which can be used to filter routes down to desired categories only. You could use this to only nominate the routes you desire. Or,It's a bit hard to know exactly what you're asking here, because I'm not sure what your output pasted above actually is - it seems to have all possible routes all mixed together in one data.frame
, and so can not actually be the direct output of gtfs_route()
. As for your second question: it really should not happen that a transfer leaves before it arrives - the 170X should never connect with B9 at Wynyard Station. If that really is what happens, then we indeed have a problem that needs to be resolved. But for that, we would need some actual reproducible code, which is i think is ultimately what is required to progress here. So could you please:
reprex::reprex()
?setwd ("<my>/<directory>") # and delete those details from version you paste here
if (!file.exists ("sydney-gtfs.zip")) { # or whatever you call your local file
download.file (url = "<url>/<to>/<gtfs>/<zip>/<file>.zip")
if (!file.exists ("sydney-with-transfers.Rds")) {
gtfs <- extract_gtfs("sydney-gtfs.zip")
gtfs <- gtfs_transfer_table (gtfs) # plus any other parameters you've set
saveRDS (gtfs, file = "sydney-with-transfers.Rds")
} else {
gtfs <- readRDS ("sydney-with-transfers.Rds")
}
# ... then on with the code necessary to reproduce your observations described above
Thanks!
Excellent! Thank you very much for your quick answer!
I've tried more options in gtfs_route(), route_pattern doesn't change my result but max_transfers and earliest_arrival helped filter many cases. However, there is still some blends if the ODs route returns many options.
I will create a reproducible example and add it as an additional comment.
Thanks @loanho23. Note also that I found a bit of a bug in the code which led to some strange-looking routes appearing. Please make sure that you re-install the latest dev version before proceeding. That alone might go some way to fixing some of your previous issues.
Many thanks @mpadge.
After installing the latest version as you suggested, most of the routes were improved. Appreciated lots.
I have another question that when I set max_transfers = 2, the result still returned more than 2 transfers( the test file attached with the scripts below). I am wondering how you considered number of transfers? Is that based on trip_id or trip_name or something else?
selected_greater_sydney_gtfs_static.zip
library(gtfsrouter)
gtfstest <- extract_gtfs("selected_greater_sydney_gtfs_static.zip") gtfstest$transfers <- gtfs_transfer_table(gtfstest, d_limit = 500, min_transfer_time = 120) gtfsprepared <- gtfs_timetable(gtfstest, day = "tu")
routetest<-gtfs_route(gtfsprepared, from="Pittwater High School, Mona St",to="Central Station", start_time=360010+(6022), max_transfers = 2, earliest_arrival = TRUE)
Thank you very much for your interaction and help!
The commit linked above updates the description of the max_transfers
parameter which should hopefully now explain why you still see more than 2 transfers. The updated description reads:
\item{max_transfers}{If not \code{NA}, specify a desired maximum number of transfers for the route (including but not exceeding this number). This parameter may be used to generate alternative routes with fewer transfers, although actual numbers of transfers may still exceed this number if a value is specified which exceeds the minimal feasible number of transfers.}
That parameter should perhaps be replaced with something more directly usable like a minimise_transfers = FALSE
option, but hopefully at least in the current form that is sufficiently clear why you can not reduce numbers of transfers - it is simply not possible to get from Pittwater to Central Station with the feed data as given there with less than 4 transfers.
Hi Developers,
I ran the gtfsrouter and had the table below with the 3 route options between this OD:
I interpreted these 3 routes based on my knowledge of Sydney, but I believe you have better idea how to classify and select appropriate routes from the source code.
I have 2 questions:
Thank you very much.
gtfsrouter::gtfs_route (gtfswithtransfersprep, include_ids = FALSE, from = as.character("Sydney Rd At Austin St"), to = as.character("Central Station"), start_time = 7 3600 + 6014, day = "tu")
I really appreciate your development of this package which is very useful to create route options from the whole timetable. Loan