switching to lat lon buckets instead of pdist

This commit is contained in:
Ben Varick 2024-11-19 13:37:11 -06:00
parent 72df5362b5
commit c98fe88d40
No known key found for this signature in database

View File

@ -60,8 +60,14 @@ metro_data <- metro_raw %>%
lag_time = lag(time)) %>% lag_time = lag(time)) %>%
mutate(lag_spd = (pdist - lag_pdist)/as.double(difftime(time, lag_time, units = "hours"))/5280) mutate(lag_spd = (pdist - lag_pdist)/as.double(difftime(time, lag_time, units = "hours"))/5280)
routes_categorized <- read_csv(file = "routes_categorized.csv", col_types = "cc")
bucket_lat <- 364481.35/200
bucket_lon <- 267203.05/200
metro_summary <- metro_data %>% metro_summary <- metro_data %>%
mutate(pdist_bucket = round(pdist / 200) * 100) %>% left_join(routes_categorized, by = "pid") %>%
mutate(lat_bucket = round(lat / 200) * 100) %>%
group_by(pdist_bucket, rt, des, pid) %>% group_by(pdist_bucket, rt, des, pid) %>%
summarise(lat = median(lat, na.rm = TRUE), summarise(lat = median(lat, na.rm = TRUE),
lon = median(lon, na.rm = TRUE), lon = median(lon, na.rm = TRUE),
@ -112,7 +118,6 @@ bbox <- c(left = min(metro_data$lon),
basemap <- get_stadiamap(bbox = bbox, zoom = 13, maptype = "stamen_toner_lite") basemap <- get_stadiamap(bbox = bbox, zoom = 13, maptype = "stamen_toner_lite")
# A West # A West
routes_categorized <- read_csv(file = "routes_categorized.csv", col_types = "cc")
quantile(segments_sf %>% filter(pid %in% c("469")) %>% pull(lag_spd), c(0,0.25, 0.5, 0.75, 1)) quantile(segments_sf %>% filter(pid %in% c("469")) %>% pull(lag_spd), c(0,0.25, 0.5, 0.75, 1))
for (route in unique(routes_categorized$name)){ for (route in unique(routes_categorized$name)){