From d559b8605eb5bb9f593294fd415b61bb1f270be0 Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Tue, 5 Nov 2024 09:07:18 -0600 Subject: [PATCH] added 'student_number' to routes data table --- cycling_route_analysis_brouter.Rmd | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cycling_route_analysis_brouter.Rmd b/cycling_route_analysis_brouter.Rmd index 0c2baf0..c3fcfd7 100644 --- a/cycling_route_analysis_brouter.Rmd +++ b/cycling_route_analysis_brouter.Rmd @@ -137,18 +137,20 @@ routes <- list(NULL) 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)) { query <- paste0( - brouter_url, - "?lonlats=", - (addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][1], ",", - (addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][2], "|", - school_focus_location$LON, ",", school_focus_location$LAT, - "&profile=", brouter_profile, - "&alternativeidx=0&format=geojson" -) + brouter_url, + "?lonlats=", + (addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][1], ",", + (addresses_near %>% filter(number == i) %>% pull(point) %>% str_split(., ","))[[1]][2], "|", + school_focus_location$LON, ",", school_focus_location$LAT, + "&profile=", brouter_profile, + "&alternativeidx=0&format=geojson" + ) response <- GET(query) - routes[[i]] <- st_read(content <- content(response, as = "text"), quiet = TRUE) - - + route_run <- 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))) }