Loading multiple GTFS.zip format files in r5r

194 views Asked by At

I am trying to analyze trips in a long time period in r5r that requires more than one GTFS files. I am using a for loop since I want to study trips in various depature dates in the Excel file. Right now, I have placed all three GTFS.zip files with different names in the data path together, but I could only receive mode information by public transportation within one date range, while trips in the other two dates produced walk time only. Is there a way to let r5r include all of them?

options(java.parameters = "-Xmx16G")
library(r5r)
library(sf)
library(data.table)

File_Path = file.path("C:","Research", "Data Sep", fsep = .Platform$file.sep)
list.files(File_Path)
poi <- fread(file.path(File_Path, "OriginsDestinationsPugetSound.csv"))

r5r_core <- setup_r5(data_path = File_Path, verbose = TRUE)
mode <- c("WALK","TRANSIT")

max_walk_dist <- 1000 # in meters
max_trip_duration <- 300 # in minutes

LengthOfFile = length(poi[[1]]) 
ListOfDetailedItineries = (matrix(ncol = 15,nrow = 0))

start = 1
end = 25

for (i in start:end) {

OriginPoint = poi[i,2:4]
DestinationPoint = poi[i,5:7]
Time_of_Trip = poi[i,9]
departure_datetime = as.POSIXct(Time_of_Trip[[1]], format = "%m/%d/%Y %H:%M")

dit <- detailed_itineraries(r5r_core = r5r_core,
                            origins = OriginPoint,
                            destinations = DestinationPoint,
                            mode = mode,
                            departure_datetime = departure_datetime,
                            max_walk_dist = max_walk_dist,
                            max_trip_duration = max_trip_duration,
                            shortest_path = TRUE,
                            verbose = TRUE)

ListOfDetailedItineries =  rbind(ListOfDetailedItineries, as.matrix(dit))

cat('On iteration ',i,'\n',dit[[9]],"\n")
flush.console()

}

dit1 = as.data.frame(ListOfDetailedItineries)
1

There are 1 answers

0
dhersz On

As far as I understood, you have 3 feeds inside your data directory and you tried to generate travel time estimates for 3 different departure times, but only one of them return transit public transport trips. Is that correct?

If that's the case, you have to make sure that the public transit services listed in your GTFS feeds run on your specified departure times. This information is usually listed in the calendar table, but can also be listed in the calendar_dates table in some feeds.

The best practice here would be to choose dates that fall inside the service intervals of all 3 of your feeds. Alternatively, you can edit the start_date/end_date columns of their calendar table to include the days you have already chosen.