Compare commits
No commits in common. "d559b8605eb5bb9f593294fd415b61bb1f270be0" and "ef51272a69c549e99fda8f6cd404ff4afa753f9d" have entirely different histories.
d559b8605e
...
ef51272a69
@ -71,16 +71,15 @@ bike_lts_scale <- data.frame(code = c(1, 2, 3, 4, 9),
|
|||||||
## Open Source Routing Machine (OSRM)
|
## Open Source Routing Machine (OSRM)
|
||||||
|
|
||||||
```{r osrm, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
```{r osrm, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||||
# Set url and profile of OSRM server
|
|
||||||
options(osrm.server = "http://127.0.0.1:5001/")
|
options(osrm.server = "http://127.0.0.1:5001/")
|
||||||
options(osrm.profile = "bike")
|
options(osrm.profile = "bike")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Brouter options
|
## Brouter options
|
||||||
```{r brouter, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
```{r brouter, eval = TRUE, echo = TRUE, results = "show", warning = FALSE, error = TRUE, message = FALSE}
|
||||||
# Set url and profile of brouter server
|
# Prepare the URL query
|
||||||
brouter_url <- "http://127.0.0.1:17777/brouter"
|
url <- "http://127.0.0.1:17777/brouter"
|
||||||
brouter_profile <- "trekking"
|
profile <- "trekking" # choose appropriate profile
|
||||||
```
|
```
|
||||||
|
|
||||||
## Stadia Maps API Key
|
## Stadia Maps API Key
|
||||||
@ -137,18 +136,16 @@ routes <- list(NULL)
|
|||||||
school_focus_location <- WI_schools %>% filter(NCES_CODE %in% school_focus$NCES_CODE) %>% select(LAT, LON)
|
school_focus_location <- WI_schools %>% filter(NCES_CODE %in% school_focus$NCES_CODE) %>% select(LAT, LON)
|
||||||
for(i in addresses_near %>% arrange(number) %>% pull(number)) {
|
for(i in addresses_near %>% arrange(number) %>% pull(number)) {
|
||||||
query <- paste0(
|
query <- paste0(
|
||||||
brouter_url,
|
url,
|
||||||
"?lonlats=",
|
"?lonlats=",
|
||||||
(addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][1], ",",
|
(addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][1], ",",
|
||||||
(addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][2], "|",
|
(addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][2], "|",
|
||||||
school_focus_location$LON, ",", school_focus_location$LAT,
|
school_focus_location$LON, ",", school_focus_location$LAT,
|
||||||
"&profile=", brouter_profile,
|
"&profile=", profile,
|
||||||
"&alternativeidx=0&format=geojson"
|
"&alternativeidx=0&format=geojson"
|
||||||
)
|
)
|
||||||
response <- GET(query)
|
response <- GET(query)
|
||||||
route_run <- st_read(content <- content(response, as = "text"), quiet = TRUE)
|
routes[[i]] <- st_read(content <- content(response, as = "text"), quiet = TRUE)
|
||||||
route_run[["student_number"]] <- i
|
|
||||||
routes[[i]] <- route_run
|
|
||||||
|
|
||||||
|
|
||||||
message(paste0("done - ", i, " of ", max(addresses_near$number)))
|
message(paste0("done - ", i, " of ", max(addresses_near$number)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user