added route categories and maps
This commit is contained in:
parent
eab18f7e05
commit
72df5362b5
@ -61,7 +61,7 @@ metro_data <- metro_raw %>%
|
||||
mutate(lag_spd = (pdist - lag_pdist)/as.double(difftime(time, lag_time, units = "hours"))/5280)
|
||||
|
||||
metro_summary <- metro_data %>%
|
||||
mutate(pdist_bucket = round(pdist / 500) * 500) %>%
|
||||
mutate(pdist_bucket = round(pdist / 200) * 100) %>%
|
||||
group_by(pdist_bucket, rt, des, pid) %>%
|
||||
summarise(lat = median(lat, na.rm = TRUE),
|
||||
lon = median(lon, na.rm = TRUE),
|
||||
@ -111,24 +111,37 @@ bbox <- c(left = min(metro_data$lon),
|
||||
#get basemap
|
||||
basemap <- get_stadiamap(bbox = bbox, zoom = 13, maptype = "stamen_toner_lite")
|
||||
|
||||
# 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))
|
||||
|
||||
ggmap(basemap) +
|
||||
labs(title = "Metro Route Speed",
|
||||
subtitle = paste0("averaged between ",
|
||||
metro_summary %>% filter(pid %in% c("1280")) %>% pull(trip_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 = segments_sf %>% filter(pid %in% c("1280")),
|
||||
inherit.aes = FALSE,
|
||||
aes(color = lag_spd),
|
||||
linewidth = 1) +
|
||||
scale_color_distiller(palette = "RdYlGn", direction = "reverse", limits = c(0,70), name = "Average speed\n(calculated with consecutive points)") +
|
||||
facet_wrap(paste0(rt, "-", des) ~ .)
|
||||
for (route in unique(routes_categorized$name)){
|
||||
route_focus <- routes_categorized %>% filter(name == route) %>% pull(pid)
|
||||
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 = segments_sf %>% filter(pid %in% route_focus),
|
||||
inherit.aes = FALSE,
|
||||
aes(color = lag_spd),
|
||||
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)")
|
||||
ggsave(file = paste0("figures/",
|
||||
route,
|
||||
".pdf"),
|
||||
title = paste0("Metro Route Speed - ", route),
|
||||
device = pdf,
|
||||
height = 8.5,
|
||||
width = 11,
|
||||
units = "in",
|
||||
create.dir = TRUE)
|
||||
}
|
||||
|
11
routes_categorized.csv
Normal file
11
routes_categorized.csv
Normal file
@ -0,0 +1,11 @@
|
||||
name,pid
|
||||
A_West,469
|
||||
A_West,387
|
||||
A_West,362
|
||||
A_East,421
|
||||
A_East,414
|
||||
A_East,422
|
||||
A_East,1277
|
||||
B_North,1276
|
||||
B_North,1280
|
||||
B_South,503010
|
|
Loading…
x
Reference in New Issue
Block a user