Skip to content

Error with TRANSIT mode: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException #431

@Fang822

Description

@Fang822

I'm experiencing an issue when using the travel_time_matrix() function with TRANSIT as a mode. When my OD dataset contains only WALK or BICYCLE, everything runs fine. However, when there are OD pairs with TRANSIT, I get the following error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException

I saw some previous issues where you suggested checking for errors in the GTFS dataset. I have already validated and corrected the GTFS data, but the problem persists. Could you help me identify what might be causing this error?

Below is a minimal reproducible example with sample OD data:

https://drive.google.com/drive/folders/1mojWAO-NPVNi8uHqhm6O44eMmw5fL4vM?usp=drive_link

library(r5r)
library(sf)
library(data.table)
library(ggplot2)
library(akima)
library(dplyr)
library(rJava)
library(openxlsx)

options(java.parameters = "-Xmx16G")

data_path <- "Z:/Lahti/roadnetwork"
r5r_core <- setup_r5(data_path, verbose = FALSE)

od_data <- fread("Z:/Lahti/OD/Exampledata.csv")

results <- lapply(1:nrow(od_data), function(i) {

origin <- data.frame(id = as.character(i), lat = od_data$origin_lat[i], lon = od_data$origin_lon[i])
destination <- data.frame(id = as.character(i), lat = od_data$destination_lat[i], lon = od_data$destination_lon[i])
mode <- od_data$mode[i]

origin <- bind_rows(origin)
destination <- bind_rows(destination)

travel_time <- travel_time_matrix(r5r_core = r5r_core,
origins = origin,
destinations = destination,
mode = mode,
departure_datetime = as.POSIXct("2025-03-24 09:00:00"),
max_walk_time = 60,
max_trip_duration = 300)

#print(travel_time)

travel_time$id <- i

return(travel_time)
})

final_results <- rbindlist(results, fill = TRUE)

write.xlsx(final_results,"Z:/Lahti/result/exampleresult.xlsx")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions