diff --git a/.gitignore b/.gitignore index a609cd0..da4a557 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ api_key R/route_analysis.html log/ # Exclude html files generated in the top directory (from RStudio runs) -./*.html +*.html diff --git a/README.md b/README.md index 929db12..0adf224 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,12 @@ This script will generate a few figures: ### A map of all the walking routes within the walk boundary: ![example routes figure](examples/example-routes.png) -### A map of those routes colored by the level of traffic stress to bike +### A map of those walking routes colored by the level of traffic stress to bike ![example routes-lts figure](examples/example-routes-lts.png) +### A map of cycling routes colored by the level of traffic stress to bike (with a 3 mile radius) +![example routes-lts figure](examples/example-routes-lts_cycling.png) + ## Using make - `make osrm-data`: downloads the OpenStreetMap data for Wisconsin, and preproccesses it for use with OSRM. - `make osrm-container`: starts the OSRM containers (backends and frontends) for walking and biking. diff --git a/cycling_route_analysis.Rmd b/cycling_route_analysis.Rmd index 3e9afaa..7116a91 100644 --- a/cycling_route_analysis.Rmd +++ b/cycling_route_analysis.Rmd @@ -140,7 +140,7 @@ Notes: ## Combine routes with Bike LTS -```{r routeslts, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} +```{r ltscount, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} # Count the routes that intersect or overlap with each segment of the bike_tls network. # The intersections have a buffer of 20m @@ -148,11 +148,9 @@ bike_lts_buffer <- st_buffer(st_intersection(bike_lts, cycle_boundary_poly), 20) bike_lts_buffer["student_use"] <- unlist(lapply(st_intersects(bike_lts_buffer, routes), length)) -bike_lts <- st_join(bike_lts, bike_lts_buffer %>% select(OBJECTID, student_use)) +bike_lts <- left_join(bike_lts, as.data.frame(bike_lts_buffer %>% select(OBJECTID, student_use)), by = "OBJECTID") ``` - -Notes: - +Notes: for each segment in bike_lts, this counts how many student's calculated routes intersect with it (within a 20 m buffer) # Make Maps diff --git a/cycling_route_analysis_brouter.Rmd b/cycling_route_analysis_brouter.Rmd index c3fcfd7..86f78d6 100644 --- a/cycling_route_analysis_brouter.Rmd +++ b/cycling_route_analysis_brouter.Rmd @@ -162,7 +162,7 @@ Notes: ## Combine routes with Bike LTS -```{r routeslts, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} +```{r ltscount, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} # Count the routes that intersect or overlap with each segment of the bike_tls network. # The intersections have a buffer of 20m @@ -170,11 +170,23 @@ bike_lts_buffer <- st_buffer(st_intersection(bike_lts, cycle_boundary_poly), 20) bike_lts_buffer["student_use"] <- unlist(lapply(st_intersects(bike_lts_buffer, routes), length)) -bike_lts <- st_join(bike_lts, bike_lts_buffer %>% select(OBJECTID, student_use)) +bike_lts <- left_join(bike_lts, as.data.frame(bike_lts_buffer %>% select(OBJECTID, student_use)), by = "OBJECTID") ``` -Notes: +Notes: for each segment in bike_lts, this counts how many student's calculated routes intersect with it (within a 20 m buffer) +```{r routeslts, eval = FALSE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} +routes_lts <-list(NULL) +for(i in addresses_near %>% arrange(number) %>% pull(number)) { + lts_segments <- st_intersects(routes %>% filter(student_number == i), bike_lts_buffer) + lts_max <- max(bike_lts_buffer %>% filter(OBJECTID.x )) + routes_lts[[i]] <- routes_lts_run + message(paste0("done - ", i, " of ", max(addresses_near$number))) +} +routes_lts <- bind_rows(routes_lts) +``` + +Notes: for each student's route, this finds which bike_lts segment it intersects with and calculates a max and an average # Make Maps diff --git a/examples/example-addresses.png b/examples/example-addresses.png index d73ca88..ebdccac 100644 Binary files a/examples/example-addresses.png and b/examples/example-addresses.png differ diff --git a/examples/example-routes-lts.png b/examples/example-routes-lts.png index c2799f9..c6a3366 100644 Binary files a/examples/example-routes-lts.png and b/examples/example-routes-lts.png differ diff --git a/examples/example-routes-lts_cycling.png b/examples/example-routes-lts_cycling.png new file mode 100644 index 0000000..0048b75 Binary files /dev/null and b/examples/example-routes-lts_cycling.png differ diff --git a/examples/example-routes.png b/examples/example-routes.png index 37c04b2..b0d8682 100644 Binary files a/examples/example-routes.png and b/examples/example-routes.png differ diff --git a/route_analysis.Rmd b/route_analysis.Rmd index 07ba8c3..35d189f 100644 --- a/route_analysis.Rmd +++ b/route_analysis.Rmd @@ -114,7 +114,7 @@ routes <- bind_rows(routes) ## Combine routes with Bike LTS -```{r routeslts, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} +```{r ltscount, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} # Count the routes that intersect or overlap with each segment of the bike_tls network. # The intersections have a buffer of 20m @@ -122,8 +122,9 @@ bike_lts_buffer <- st_buffer(st_intersection(bike_lts, walk_boundary_poly), 20) bike_lts_buffer["student_use"] <- unlist(lapply(st_intersects(bike_lts_buffer, routes), length)) -bike_lts <- st_join(bike_lts, bike_lts_buffer %>% select(OBJECTID, student_use)) +bike_lts <- left_join(bike_lts, as.data.frame(bike_lts_buffer %>% select(OBJECTID, student_use)), by = "OBJECTID") ``` +Notes: for each segment in bike_lts, this counts how many student's calculated routes intersect with it (within a 20 m buffer) # Make Maps