This notebook processes Replica weekday network edge volumes and simplifies the dataset into a wide format shapefile, with columns that indicate volumes by mode and work/non-work purpose. These represent 24-hour volumes on typical weekday conditions during the modeled period of 2Q2021.

setwd("C:/Users/z_rpg/EPR, PC/Richmond Connects - General")
edges <- readRDS("2.2_Data/RAW/replica_trips_and_pop/network/replica_21_richmond_city_network_edges.rds") %>% 
  dplyr::select(stableEdgeId, highway)

volumes <- readRDS("2.2_Data/RAW/replica_trips_and_pop/edge_volume_thur_21_long.Rds") %>% 
  mutate(mode = case_when(mode == "CARPOOL" ~ "AUTO",
                          mode == "ON_DEMAND_AUTO" ~ "AUTO",
                          mode == "PRIVATE_AUTO" ~ "AUTO",
                          TRUE ~ mode),
         travel_purpose = case_when(travel_purpose == "WORK" ~ "WORK",
                                    TRUE ~ "NON-WORK")) %>% 
  group_by(segment, mode, travel_purpose) %>% 
  summarise(trips = sum(trips)) %>% 
  pivot_wider(names_from = c(mode, travel_purpose),
              values_from = trips) %>%
  clean_names() %>%
  rename(autoNwrk = auto_non_work,
         autoWrk = auto_work,
         bikeNwrk = biking_non_work,
         bikeWrk = biking_work,
         tranNwrk = public_transit_non_work,
         tranWrk = public_transit_work,
         wlkNwrk = walking_non_work,
         wlkWrk = walking_work) %>% 
  mutate(wlkAll = wlkNwrk + wlkWrk,
         bikeAll = bikeNwrk + bikeWrk,
         autoAll = autoNwrk + autoWrk,
         tranAll = tranNwrk + tranWrk) %>%
  mutate_all(~replace(., is.na(.), 0)) %>% 
  rename(stableEdgeId = segment)

volumes_sf <- left_join(edges,
                        volumes)

st_write(volumes_sf,
         "2.2_Data/PROCESSED/Network_Volumes_Replica/network_vol_simp_replica.shp")
## Writing layer `network_vol_simp_replica' to data source 
##   `2.2_Data/PROCESSED/Network_Volumes_Replica/network_vol_simp_replica.shp' using driver `ESRI Shapefile'
## Writing 69589 features with 14 fields and geometry type Line String.

Data Output

The following table identifies the values in each column present in the shapefile

Shapefile Field Names
Shapefile Column Name Mode Purpose
autoNwrk Auto Non-Work
autoWrk Auto Work
autoAll Auto All
bikeNwork Bicycle Non-Work
bikeWrk Bicycle Work
bikeAll Bicycle All
tranNwrk Transit Non-Work
tranWrk Transit Work
tranAll Transit All
wlkNwrk Walk Non-Work
wlkWrk Walk Work
wlkAll Walk All

QC Map

A faceted map is produced illustrating volumes for tertiary and higher grade links.

volumes_sf_long <- volumes_sf %>% 
  pivot_longer(4:15,
               names_to = "theme",
               values_to = "volume") %>% 
  dplyr::filter(highway %in% c("motorway_link", "motorway", "primary", "primary_link", "trunk", "secondary", "secondary_link", "tertiary")) %>% 
  arrange(volume)

tm_shape(volumes_sf_long) + tm_lines("volume", style = "fisher", n = 7, palette = "viridis") +
  tm_facets(by = "theme", free.scales = T)