Compare commits
No commits in common. "f3e68912ad2f61f266035b4647f27057c4e964b8" and "626d69667e415dfb781f6eab0b2e651805244019" have entirely different histories.
f3e68912ad
...
626d69667e
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,4 +20,3 @@ archive/
|
||||
trash/
|
||||
api_key
|
||||
R/route_analysis.html
|
||||
log/
|
||||
|
@ -7,7 +7,7 @@ output:
|
||||
toc_float:
|
||||
collapsed: false
|
||||
smooth_scroll: true
|
||||
editor_options:
|
||||
editor_options:
|
||||
chunk_output_type: console
|
||||
---
|
||||
|
||||
@ -35,7 +35,6 @@ set.seed(1)
|
||||
```{r gpkg, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||
WI_schools <- st_transform(st_read(dsn = "data/Schools/Wisconsin_Public_Schools_-5986231931870160084.gpkg"), crs = 4326)
|
||||
WI_schools <- WI_schools %>% mutate(geom = SHAPE)
|
||||
# names(WI_schools)
|
||||
```
|
||||
|
||||
## Addresses Data
|
||||
@ -43,9 +42,8 @@ WI_schools <- WI_schools %>% mutate(geom = SHAPE)
|
||||
```{r addresses, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||
addresses <- read_csv(file="data/addresses/Addresses_Students_EastHS_2024_GeocodeResults.csv") %>%
|
||||
filter(lat > 0) %>%
|
||||
st_as_sf(coords=c("lon","lat"), crs=4326)
|
||||
st_as_sf(coords=c("lon","lat"), crs=4326) # remember x=lon and y=lat
|
||||
```
|
||||
(Remember that x = lon and y = lat.)
|
||||
|
||||
## Bike Level of Traffic Stress (LTS)
|
||||
|
||||
@ -79,13 +77,14 @@ options(osrm.profile = "walk")
|
||||
```{r stadiamaps, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||
register_stadiamaps(key = substr(read_file(file = "api_keys/stadia_api_key"), 1, 36))
|
||||
```
|
||||
|
||||
# Analysis
|
||||
|
||||
## Subset Addresses Within 1.5 Miles
|
||||
|
||||
```{r walkBoundary, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||
walk_boundary_m <- 1.5*1609
|
||||
school_focus <- data.frame(name = c("East High School"), NCES_CODE = c("550852000925"))
|
||||
walk_boundary_m <- 1.5 * 1609 ## walk boundary
|
||||
school_focus <- data.frame(name = c("East High School"), NCES_CODE = c("550852000925")) ## school focus
|
||||
|
||||
walk_boundary_poly <- fill_holes(st_make_valid(osrmIsodistance(
|
||||
loc = WI_schools %>% filter(NCES_CODE %in% school_focus$NCES_CODE),
|
||||
@ -96,19 +95,18 @@ walk_boundary_poly <- fill_holes(st_make_valid(osrmIsodistance(
|
||||
addresses_near <- st_intersection(addresses, walk_boundary_poly)
|
||||
```
|
||||
|
||||
## Calculate Routes
|
||||
## Calculate walking routes for each student
|
||||
|
||||
```{r routes, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||
routes <- list(NULL)
|
||||
|
||||
## calculate routes
|
||||
routes <- list(NULL)
|
||||
for(i in addresses_near$number) {
|
||||
routes[[i]] <- osrmRoute(
|
||||
src = addresses_near %>% filter(number == i),
|
||||
dst = WI_schools %>% filter(NCES_CODE %in% school_focus$NCES_CODE))
|
||||
message(paste0("done - ", i, "of", max(addresses_near$number)))
|
||||
}
|
||||
|
||||
|
||||
routes <- bind_rows(routes)
|
||||
```
|
||||
|
||||
@ -125,8 +123,7 @@ bike_lts_buffer["student_use"] <- unlist(lapply(st_intersects(bike_lts_buffer, r
|
||||
bike_lts <- st_join(bike_lts, bike_lts_buffer %>% select(OBJECTID, student_use))
|
||||
```
|
||||
|
||||
# Make Maps
|
||||
|
||||
# Generate Maps
|
||||
|
||||
## Load school and Bike Fed logo
|
||||
```{r logos, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||
@ -286,7 +283,6 @@ ggmap(basemap) +
|
||||
nudge_y = 0.0015,
|
||||
label.size = 0.04,
|
||||
size = 2)
|
||||
|
||||
ggsave(file = paste0("figures/",
|
||||
school_focus %>% pull(name),
|
||||
" Routes - Traffic Stress.pdf"),
|
||||
@ -297,6 +293,9 @@ ggsave(file = paste0("figures/",
|
||||
units = "in",
|
||||
create.dir = TRUE)
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
# Appendix
|
||||
|
Loading…
x
Reference in New Issue
Block a user