Compare commits

..

11 Commits

Author SHA1 Message Date
Ben Varick
ef51272a69
added brouter to readme intro 2024-11-05 08:27:07 -06:00
Ben Varick
dd36d8b957
added top level .html files to .gitignore
and edited a note in cycling_route_analysis_brouter.Rmd
2024-11-05 08:15:00 -06:00
Ben Varick
fe88172a3b
edited typo in Makefile 2024-11-05 07:59:38 -06:00
Ben Varick
378c991c6d
added docker-compose to brouter docker directory 2024-11-05 07:53:23 -06:00
Ben Varick
104f215a0e
Edited .gitignore, edited README, edited Makefile
to include new brouter make commands
2024-11-05 07:52:14 -06:00
Ben Varick
24dacb5e6b
added download wisconsin-latest.osm.pbf to makefile 2024-11-05 07:43:32 -06:00
Ben Varick
7993621f9f
changed docker directory structure, added brouter 2024-11-05 07:29:34 -06:00
bvarick
7932dad4bd
Merge pull request #10 from syounkin/sgy
Added docker Commands to Makefile
2024-11-04 18:57:18 -06:00
syounkin
2e1c211915 Merge branch 'main' into sgy 2024-11-04 18:52:16 -06:00
syounkin
14b8a14284 Added link to OSM data to README 2024-11-04 18:50:47 -06:00
syounkin
6455542eac Added docker commands to Makefile
make data and make container can be used to pre-process the data and spawn the docker containers.
2024-11-04 18:50:21 -06:00
12 changed files with 137 additions and 5 deletions

2
.gitignore vendored
View File

@ -21,3 +21,5 @@ trash/
api_key api_key
R/route_analysis.html R/route_analysis.html
log/ log/
# Exclude html files generated in the top directory (from RStudio runs)
./*.html

View File

@ -1,9 +1,35 @@
walk: route_analysis.Rmd 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")' 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")'
cycle: cycling_route_analysis.Rmd cycle_osrm: cycling_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 = "./cycling_route_analysis.Rmd", output_file = "./html/cycling_route_analysis.html")' 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 = "./cycling_route_analysis.Rmd", output_file = "./html/cycling_route_analysis.html")'
cycle_brouter: cycling_route_analysis_brouter.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 = "./cycling_route_analysis_brouter.Rmd", output_file = "./html/cycling_route_analysis.html")'
osrm-container: ./docker/osrm/docker-compose.yml
cd ./docker/osrm/; docker compose up -d
osrm-data:
cd ./docker/osrm/; wget https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf -O ./data-raw/wisconsin-latest.osm.pbf
cd ./docker/osrm/; docker run -t -v "./data-foot:/data" -v "./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf" osrm/osrm-backend osrm-extract -p /opt/foot.lua /data/wisconsin-latest.osm.pbf
cd ./docker/osrm/; docker run -t -v "./data-foot:/data" -v "./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf" osrm/osrm-backend osrm-partition /data/wisconsin-latest.osrm
cd ./docker/osrm/; docker run -t -v "./data-foot:/data" -v "./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf" osrm/osrm-backend osrm-customize /data/wisconsin-latest.osrm
cd ./docker/osrm/; docker run -t -v "./data-bicycle:/data" -v "./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf" osrm/osrm-backend osrm-extract -p /opt/bicycle.lua /data/wisconsin-latest.osm.pbf
cd ./docker/osrm/; docker run -t -v "./data-bicycle:/data" -v "./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf" osrm/osrm-backend osrm-partition /data/wisconsin-latest.osrm
cd ./docker/osrm/; docker run -t -v "./data-bicycle:/data" -v "./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf" osrm/osrm-backend osrm-customize /data/wisconsin-latest.osrm
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/; wget -i segments.csv -P ./brouter/misc/segments4/
cd ./docker/brouter/; 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: clean-data clean-figure clean-script
clean-data: clean-data:
@ -16,3 +42,4 @@ clean-figure:
rm -rvf ./figure/ rm -rvf ./figure/
.PHONY: data .PHONY: data

View File

@ -2,7 +2,7 @@
This script generates maps to analyze the potential walking routes for students to their school. This script generates maps to analyze the potential walking routes for students to their school.
- I excluded the addresses of the students from the repository. - I excluded the addresses of the students from the repository.
- The actual route generation is done with OSRM, I run it locally in a docker container. - The actual route generation is done with OSRM and brouter, those are run locally in docker containers.
- The basemap is pulled from Stadia Maps. The usage of the script is well within the free tier, you'll need an API key from them. - The basemap is pulled from Stadia Maps. The usage of the script is well within the free tier, you'll need an API key from them.
## Data sources ## Data sources
@ -22,8 +22,17 @@ This script will generate a few figures:
![example routes-lts figure](examples/example-routes-lts.png) ![example routes-lts figure](examples/example-routes-lts.png)
## Using make ## Using make
The command `make route_analysis` will run *route_analysis.Rmd* which - `make osrm-data`: downloads the OpenStreetMap data for Wisconsin, and preproccesses it for use with OSRM.
is an R markdown file containing the original R script *route_analysis.R* - `make osrm-container`: starts the OSRM containers (backends and frontends) for walking and biking.
- `make brouter-data`: clones the repositories for brouter and brouter-web and downloads the segment data. It also builds the docker images for brouter and brouter-web.
- `make brouter-container`: starts the brouter containers (backend and frontend).
- `make walk` will run *route_analysis.Rmd* which
calculates the walking routes using OSRM.
- `make cycle-osrm` will run *cycling_route_analysis.Rmd* which calculates the biking routes using OSRM.
- `make cycle-brouter` will run *cycling_route_analysis_brouter.Rmd* which calculates the biking routes using brouter.
## Misc. ## Misc.
- [Bike Level of Traffic Stress (LTS)](https://www.dvrpc.org/webmaps/bike-lts/analysis/) - [Bike Level of Traffic Stress (LTS)](https://www.dvrpc.org/webmaps/bike-lts/analysis/)
## OpenStreetMap Data
- [wisconsin-latest.osm.pbf](https://download.geofabrik.de/north-america/us/wisconsin-latest.osm.pbf)

View File

@ -155,7 +155,7 @@ routes <- bind_rows(routes)
``` ```
Notes: Notes:
- _osrmRoute_ is the primary function used above. - this queries the brouter server to get routes
## Combine routes with Bike LTS ## Combine routes with Bike LTS

10
docker/brouter/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
# Except the list of relevant segments
!segments.csv
# Except docker-compose.yml
!docker-compose.yml

View File

@ -0,0 +1,26 @@
---
services:
brouter:
container_name: brouter
ports:
- 17777:17777
volumes:
- ./brouter/misc/segments4:/segments4
image: brouter
build:
context: ./brouter
dockerfile: Dockerfile
---
services:
brouter-web:
container_name: brouter-web
ports:
- 127.0.0.1:8080:80
volumes:
- ./brouter-web/config.js:/usr/share/nginx/html/config.js
- ./brouter-web/keys.js:/usr/share/nginx/html/keys.js
- ./brouter-web/profiles:/usr/share/nginx/html/profiles
image: brouter-web
build:
context: ./brouter-web
dockerfile: Dockerfile

View File

@ -0,0 +1,4 @@
https://brouter.de/brouter/segments4/W90_N40.rd5
https://brouter.de/brouter/segments4/W90_N45.rd5
https://brouter.de/brouter/segments4/W95_N40.rd5
https://brouter.de/brouter/segments4/W95_N45.rd5
1 https://brouter.de/brouter/segments4/W90_N40.rd5
2 https://brouter.de/brouter/segments4/W90_N45.rd5
3 https://brouter.de/brouter/segments4/W95_N40.rd5
4 https://brouter.de/brouter/segments4/W95_N45.rd5

10
docker/osrm/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
!docker-compose.yml
!docker-compose-2.yml
!preprocess.sh
!data-raw/
!data-foot/
!data-bicycle/

4
docker/osrm/data-bicycle/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
docker/osrm/data-foot/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
docker/osrm/data-raw/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -0,0 +1,32 @@
---
services:
osrm-backend-foot:
container_name: osrm-backend-foot
ports:
- 5000:5000
volumes:
- ./data-foot:/data
- ./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf
image: osrm/osrm-backend
command: osrm-routed --algorithm mld /data/wisconsin-latest.osrm
osrm-backend-bicycle:
container_name: osrm-backend-bicycle
ports:
- 5001:5000
volumes:
- ./data-bicycle:/data
- ./data-raw/wisconsin-latest.osm.pbf:/data/wisconsin-latest.osm.pbf
image: osrm/osrm-backend
command: osrm-routed --algorithm mld /data/wisconsin-latest.osrm
osrm-frontend-foot:
ports:
- 9966:9966
environment:
OSRM_BACKEND: 'http://localhost:5000'
image: osrm/osrm-frontend
osrm-frontend-bicycle:
ports:
- 9967:9966
environment:
OSRM_BACKEND: 'http://localhost:5001'
image: osrm/osrm-frontend