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)
|
mutate(lag_spd = (pdist - lag_pdist)/as.double(difftime(time, lag_time, units = "hours"))/5280)
|
||||||
|
|
||||||
metro_summary <- metro_data %>%
|
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) %>%
|
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),
|
||||||
@ -111,12 +111,16 @@ bbox <- c(left = min(metro_data$lon),
|
|||||||
#get basemap
|
#get basemap
|
||||||
basemap <- get_stadiamap(bbox = bbox, zoom = 13, maptype = "stamen_toner_lite")
|
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))
|
quantile(segments_sf %>% filter(pid %in% c("469")) %>% pull(lag_spd), c(0,0.25, 0.5, 0.75, 1))
|
||||||
|
|
||||||
ggmap(basemap) +
|
for (route in unique(routes_categorized$name)){
|
||||||
labs(title = "Metro Route Speed",
|
route_focus <- routes_categorized %>% filter(name == route) %>% pull(pid)
|
||||||
|
ggmap(basemap) +
|
||||||
|
labs(title = paste0("Metro Route Speed - ", route),
|
||||||
subtitle = paste0("averaged between ",
|
subtitle = paste0("averaged between ",
|
||||||
metro_summary %>% filter(pid %in% c("1280")) %>% pull(trip_count),
|
sum(route_counts %>% filter(pid %in% route_focus) %>% pull(route_count)),
|
||||||
" bus trips - ",
|
" bus trips - ",
|
||||||
min(date(metro_data$time)),
|
min(date(metro_data$time)),
|
||||||
" to ",
|
" to ",
|
||||||
@ -126,9 +130,18 @@ ggmap(basemap) +
|
|||||||
theme(axis.text=element_blank(),
|
theme(axis.text=element_blank(),
|
||||||
axis.ticks=element_blank(),
|
axis.ticks=element_blank(),
|
||||||
plot.caption = element_text(color = "grey")) +
|
plot.caption = element_text(color = "grey")) +
|
||||||
geom_sf(data = segments_sf %>% filter(pid %in% c("1280")),
|
geom_sf(data = segments_sf %>% filter(pid %in% route_focus),
|
||||||
inherit.aes = FALSE,
|
inherit.aes = FALSE,
|
||||||
aes(color = lag_spd),
|
aes(color = lag_spd),
|
||||||
linewidth = 1) +
|
linewidth = 1) +
|
||||||
scale_color_distiller(palette = "RdYlGn", direction = "reverse", limits = c(0,70), name = "Average speed\n(calculated with consecutive points)") +
|
scale_color_distiller(palette = "RdYlGn", direction = "reverse", limits = c(0,70), name = "Average speed or segment\n(calculated with locations, not reported speed)")
|
||||||
facet_wrap(paste0(rt, "-", des) ~ .)
|
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