Description
Convert o_points to an sf object
o_points_sf <- st_as_sf(o_points, coords = c("lon", "lat"), crs = 3035)
o_points_sf <- st_transform(o_points_sf, crs = 4326)
o_points_transformed <- data.frame(
- id = o_points$id, # Retain the 'id' column
- lat = st_coordinates(o_points_sf)[, "Y"], # Latitude
- lon = st_coordinates(o_points_sf)[, "X"], # Longitude
- tot_pop = o_points$tot_pop
- )
str(o_points_transformed)
'data.frame': 131928 obs. of 4 variables:
$ id : chr "CRS3035RES100mN3187900E4566000" "CRS3035RES100mN3188000E4566100" "CRS3035RES100mN3188000E4566200" "CRS3035RES100mN3188100E4566300" ...
$ lat : num 51.7 51.7 51.7 51.7 51.7 ...
$ lon : num 13.5 13.6 13.6 13.6 13.8 ...
$ tot_pop: int 7 14 6 9 8 22 7 3 3 4 ...
head(o_points_transformed)
id lat lon tot_pop
1 CRS3035RES100mN3187900E4566000 51.74823 13.54986 7
2 CRS3035RES100mN3188000E4566100 51.74908 13.55137 14
3 CRS3035RES100mN3188000E4566200 51.74904 13.55282 6
4 CRS3035RES100mN3188100E4566300 51.74989 13.55434 9
5 CRS3035RES100mN3188100E4581600 51.74299 13.77563 8
6 CRS3035RES100mN3188100E4581700 51.74294 13.77708 22
mode <- c("WALK", "TRANSIT")
max_walk_time <- 10 # minutes
walk_speed <- 4.8 # kph
max_trip_duration <- 30 # minutesdeparture datetime
departure_datetime <- as.POSIXct("2025-03-11 09:00:00",
-
format = "%Y-%m-%d %H:%M:%S")
3.1) calculate a travel time matrix
ttm <- travel_time_matrix(
- r5r_core = r5r_core,
- origins = o_points_transformed,
- destinations = d_points,
- mode = mode,
- walk_speed = walk_speed,
- departure_datetime = departure_datetime,
- max_walk_time = max_walk_time,
- max_trip_duration = max_trip_duration
- )
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException