I am trying to use the r5r R package to create an isochrone accessibility study involving supermarkets in the City of Cleveland. I started by getting the boundary for the city, created a grid, and generated the centroids for the grid. I then used OSM to get the street network and locations of supermarkets. Finally, I created a travel time matrix using the r5r package. My code is below:
# load required packages
library(tidycensus)
library(tidytransit)
library(tmap)
library(osmdata)
library(tidyverse)
library(osmextract)
library(tigris)
library(r5r)
library(sf)
cleveland_boundary = places("Ohio") %>% filter(NAME == "Cleveland") %>% st_transform(4326)
cleveland_grid = st_make_grid(cleveland_boundary, square = FALSE, n=c(100,100),
what = "polygons") %>% st_as_sf() %>% st_filter(cleveland_boundary) %>%
mutate(id = seq(1, length(cleveland_grid$geometry), by=1)) %>% st_transform(4326)
cleveland_centroids = st_centroid(cleveland_grid)
cle_file = oe_match("Cleveland, Ohio")
cle_grocery = oe_read(cle_file$url, layer = "points", quiet = TRUE) %>%
st_transform(crs = st_crs(cleveland_boundary)) %>% st_filter(cleveland_boundary) %>%
rename(id = osm_id) %>% st_transform(4326)
dir.create("cle_network")
cleveland_streets = oe_read(cle_file$url, layer = "lines", quiet = TRUE, download_directory = "cle_network") %>%
filter(!is.na(highway)) %>%
st_transform(crs = st_crs(cleveland_boundary)) %>% st_filter(cleveland_boundary)
options(java.parameters = "-Xmx2G") # set up r5r core
r5r_core <- setup_r5("cle_network", verbose = FALSE, overwrite = TRUE)
ttm_wkday = travel_time_matrix(r5r_core = r5r_core,
origins = cle_grocery,
destinations = cleveland_centroids,
mode = c("WALK", "TRANSIT"),
departure_datetime = as.POSIXct("08-12-2022 14:00:00", format = "%d-%m-%Y %H:%M:%S"),
max_walk_dist = 1000,
max_trip_duration = 480,
verbose = FALSE)
I obtained GTFS data from [here] (https://www.riderta.com/sites/default/files/gtfs/latest/google_transit.zip) and saved it as "CLEgtfs.zip" in my cle_networks
directory created in the above code.
The output of this code only gives me 532 results, with a maximum travel time of 29 minutes. This is clearly not correct, and it seems that transit travel times are not being factored in. My guess is that it is only accounting for walk time, and since I have a maximum walking distance of 1000 meters
, I suspect only walking travel time is included in this travel time matrix. Is there any reason this may be happening? I would appreciate any guidance!
The departure datetime you're using is outside the valid range set in the
calendar.txt
of the GTFS data. The earlieststart_date
in the feed is 11/12/2022 (dd/mm/yyyy), but your departure date is 08/12/2022.Basically, none of the transit services described in the feed run on this day, so that's why you have a walk-only matrix.