Skip to content

GTFS and Elevation data affects carspeeds #458

Closed

Description

@alexmgns

Deleting GTFS and Elevation data when building the r5r_core affects the results from detailed_itineraries and ttm.

Also the routing times between detailed_itiniraries and ttm don't match. I am not sure if this is known.

I originally thought this was due to McRaptorSuboptimalPathProfileRouter but it also occurs with ttm just the difference is less noticeable.

Repex with one point:

devtools::load_all('.')

# build regular network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path, overwrite = T)
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))

departure_datetime <- as.POSIXct(
  "13-05-2019 14:00:00",
  format = "%d-%m-%Y %H:%M:%S"
)

# travel times before modifications
det <- detailed_itineraries(
  r5r_core,
  origins = points[10,],
  destinations = points[12,],
  mode = c("CAR"),
  departure_datetime = departure_datetime,
  max_trip_duration = 60
)
print(det$segment_duration)
# 22.1
ttm <- travel_time_matrix(r5r_core,   
                          origins = points[10,],
                          destinations = points[12,],    
                          mode = c("CAR"),
                          departure_datetime = departure_datetime,
                          max_trip_duration = 60)
print(ttm$travel_time_p50)
# 18

delete poa_eptc.zip

r5r_core <- setup_r5(data_path, overwrite = T)
det2 <- detailed_itineraries(
  r5r_core,
  origins = points[10,],
  destinations = points[12,],
  mode = c("CAR"),
  departure_datetime = departure_datetime,
  max_trip_duration = 60
)
print(det2$segment_duration)
# 21.3
ttm2 <- travel_time_matrix(r5r_core,   
                          origins = points[10,],
                          destinations = points[12,],    
                          mode = c("CAR"),
                          departure_datetime = departure_datetime,
                          max_trip_duration = 60)
print(ttm2$travel_time_p50)
# 18

delete poa_elevation.tif

r5r_core <- setup_r5(data_path, overwrite = T)
det3 <- detailed_itineraries(
  r5r_core,
  origins = points[10,],
  destinations = points[12,],
  mode = c("CAR"),
  departure_datetime = departure_datetime,
  max_trip_duration = 60
)
print(det3$segment_duration)
# 20.6
ttm3 <- travel_time_matrix(r5r_core,   
                          origins = points[10,],
                          destinations = points[12,],    
                          mode = c("CAR"),
                          departure_datetime = departure_datetime,
                          max_trip_duration = 60)
print(ttm3$travel_time_p50)
# 17

You can also run it with the full origin-destination pairs and then use the code below to see that there are differences in ttm if you remove gtfs data.

library(dplyr)

diff_a <- anti_join(ttm2, ttm1)
diff_b <- anti_join(ttm1, ttm2)

# View differences
View(diff_a)
View(diff_b)

Activity

  1. rafapereirabr commented on Jun 21, 2025

    @rafapereirabr
    Contributor

    Hi @BardyBard . We know detailed_itineraries and ttm return slightly different results. This is because they use different routing algorithms underneath, so this is expected.

    I was able to reproduce your results. I'm surprised that the presence of a GTFS feed affects travel times by car. I'm also a bit surprised that travel times by car are also affected by by elevation data and the impedance function of choice. I think we should open an issue over at R5 to report this. I'm not sure this is actually a bug or some expected behavior that has not been documented.

    r5r_core_tobler <- setup_r5(data_path, overwrite = T, elevation = 'TOBLER')
    r5r_core_minetti <- setup_r5(data_path, overwrite = T, elevation = 'MINETTI')
    
  2. changed the title [-]GTFS and Elevation data affects carspeeds of detailed_itineraries[/-] [+]GTFS and Elevation data affects carspeeds[/+] on Jun 25, 2025
  3. rafapereirabr commented on Jun 26, 2025

    @rafapereirabr
    Contributor

    our friends at R5 have confirmed this a bug upstream and which should be closed sometime soon.

  4. ansoncfit commented on Nov 18, 2025

    @ansoncfit

    This was addressed in conveyal/r5#972

  5. rafapereirabr commented on Nov 18, 2025

    @rafapereirabr
    Contributor

    thanks for the heads up, @ansoncfit ! this is much appreciated !

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions