From 3025cadc39df1969979d756b4448943ca9b138f1 Mon Sep 17 00:00:00 2001 From: syounkin Date: Wed, 6 Nov 2024 16:45:45 -0600 Subject: [PATCH 1/3] Update to Makefile Added all, data, containers, and cycle. Included an rm -rf in brouter-data. Previously an error was thrown when trying to clone when the directory already exists. --- Makefile | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index df1bc2e..df59fdb 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,9 @@ +all: data containers cycle + +data: osrm-data brouter-data +containers: osrm-container brouter-container +cycle: cycle_brouter + walk: route_analysis.Rmd R -e 'library("rmarkdown"); old_path <- Sys.getenv("PATH"); Sys.setenv(PATH = paste(old_path, "/usr/local/bin", sep = ":")); rmarkdown::render(knit_root_dir = "./", output_dir = "./html", input = "./route_analysis.Rmd", output_file = "./html/route_analysis.html")' @@ -23,24 +29,10 @@ brouter-container: ./docker/brouter/docker-compose.yml cd ./docker/brouter; docker compose up -d brouter-data: - cd ./docker/brouter/; git clone https://github.com/abrensch/brouter.git + cd ./docker/brouter/; rm -rf ./brouter; git clone https://github.com/abrensch/brouter.git cd ./docker/brouter/; wget -i segments.csv -P ./brouter/misc/segments4/ cd ./docker/brouter/; cp safety.brf ./brouter/misc/profiles2/safety.brf - cd ./docker/brouter/; git clone https://github.com/nrenner/brouter-web.git + cd ./docker/brouter/; rm -rf ./brouter-web; git clone https://github.com/nrenner/brouter-web.git cd ./docker/brouter/brouter-web; cp keys.template.js keys.js; cd ./docker/brouter/brouter-web; cp config.template.js config.js cd ./docker/brouter; docker compose build - -clean: clean-data clean-figure clean-script - -clean-data: - rm -vf ./R/data/*.rds - -clean-script: - rm -rvf ./*.md - -clean-figure: - rm -rvf ./figure/ - -.PHONY: data - From 14a097fe9ef4a818b920337a483f42cec0781295 Mon Sep 17 00:00:00 2001 From: syounkin Date: Wed, 6 Nov 2024 16:48:21 -0600 Subject: [PATCH 2/3] Moved basemap chunk Code in routeslts called basemap before it was defined. To correct this the basemap chunk was moved up in the script. --- cycling_route_analysis_brouter.Rmd | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/cycling_route_analysis_brouter.Rmd b/cycling_route_analysis_brouter.Rmd index f39fb6f..ba94673 100644 --- a/cycling_route_analysis_brouter.Rmd +++ b/cycling_route_analysis_brouter.Rmd @@ -161,6 +161,18 @@ routes <- st_transform(bind_rows(routes), crs = 4326) Notes: - this queries the brouter server to get routes +## Set boundaries and get basemap +```{r basemap, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} + +bbox <- st_bbox(st_buffer(cycle_boundary_poly, dist = 500)) +bbox <- c(left = as.double(bbox[1]), + bottom = as.double(bbox[2]), + right = as.double(bbox[3]), + top = as.double(bbox[4])) + +#get basemap +basemap <- get_stadiamap(bbox = bbox, zoom = 15, maptype = "stamen_toner_lite") +``` ## Combine routes with Bike LTS ```{r ltscount, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} @@ -271,19 +283,6 @@ logo <- image_read(path = "other/BFW_Logo_180_x_200_transparent_background.png") school_symbol <- image_read_svg(path = "other/school_FILL0_wght400_GRAD0_opsz24.svg") ``` -## Set boundaries and get basemap -```{r basemap, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE} - -bbox <- st_bbox(st_buffer(cycle_boundary_poly, dist = 500)) -bbox <- c(left = as.double(bbox[1]), - bottom = as.double(bbox[2]), - right = as.double(bbox[3]), - top = as.double(bbox[4])) - -#get basemap -basemap <- get_stadiamap(bbox = bbox, zoom = 15, maptype = "stamen_toner_lite") -``` - ## Generate map of addresses ```{r mapaddresses, eval = TRUE, echo = FALSE, results = "show", warning = FALSE, error = TRUE, message = FALSE} From 3a90407738b22944d613c83676ad2be76f46ab7a Mon Sep 17 00:00:00 2001 From: syounkin Date: Thu, 7 Nov 2024 09:58:34 -0600 Subject: [PATCH 3/3] Fixed bug on lines 246-247 route.lts -> route and route.geometry -> route --- cycling_route_analysis_brouter.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cycling_route_analysis_brouter.Rmd b/cycling_route_analysis_brouter.Rmd index ba94673..feff52c 100644 --- a/cycling_route_analysis_brouter.Rmd +++ b/cycling_route_analysis_brouter.Rmd @@ -255,8 +255,8 @@ routes_lts <- bind_rows(routes_lts) ggmap(basemap) + geom_sf(data = routes_lts %>% filter(student_number == 6), inherit.aes = FALSE, - aes(color = route.lts, - geometry = route.geometry), + aes(color = route$lts, + geometry = route$geometry), linewidth = 2) + scale_color_manual(values = bike_lts_scale$color, name = "Bike Level of Traffic Stress")