changed from segments to lat lon buckets

This commit is contained in:
Ben Varick 2024-11-21 17:33:44 -06:00
parent 877a8af693
commit 51806c81d4
Signed by: ben
SSH Key Fingerprint: SHA256:jWnpFDAcacYM5aPFpYRqlsamlDyKNpSj3jj+k4ojtUo

View File

@ -146,11 +146,17 @@ for (route in unique(routes_categorized$name)){
theme(axis.text=element_blank(),
axis.ticks=element_blank(),
plot.caption = element_text(color = "grey")) +
geom_sf(data = metro_segments %>% filter(name %in% route),
geom_tile(data = metro_summary %>%
filter(name %in% route) %>%
group_by(lon_bucket, lat_bucket) %>%
summarise(spd_calc = weighted.mean(spd_calc, trip_count)),
inherit.aes = FALSE,
aes(color = spd_calc),
linewidth = 1) +
scale_color_distiller(palette = "RdYlGn", direction = "reverse", limits = c(0,70), name = "Average speed or segment\n(calculated with locations, not reported speed)")
aes(x = lon_bucket,
y = lat_bucket,
fill = spd_calc,
height = lat_round,
width = lon_round)) +
scale_fill_distiller(palette = "RdYlGn", direction = "reverse", limits = c(0,70), name = "Average speed or segment\n(calculated with locations, not reported speed)")
ggsave(file = paste0("figures/",
route,
"_map.pdf"),
@ -175,3 +181,23 @@ for (route in unique(routes_categorized$name)){
units = "in",
create.dir = TRUE)
}
# ggmap(basemap) +
# labs(title = paste0("Metro Route Speed - ", route),
# subtitle = paste0("averaged between ",
# sum(route_counts %>% filter(pid %in% route_focus) %>% pull(route_count)),
# " bus trips - ",
# min(date(metro_data$time)),
# " to ",
# max(date(metro_data$time))),
# x = NULL,
# y = NULL) +
# theme(axis.text=element_blank(),
# axis.ticks=element_blank(),
# plot.caption = element_text(color = "grey")) +
# geom_sf(data = metro_segments %>% filter(name %in% route),
# inherit.aes = FALSE,
# aes(color = spd_calc),
# linewidth = 1) +
# scale_color_distiller(palette = "RdYlGn", direction = "reverse", limits = c(0,70), name = "Average speed or segment\n(calculated with locations, not reported speed)")