county case bug, added refresh basemap parameter

This commit is contained in:
Ben Varick 2025-02-06 12:47:47 -06:00
parent 38c3ba3fec
commit 3f5e6aa645
Signed by: ben
SSH Key Fingerprint: SHA256:jWnpFDAcacYM5aPFpYRqlsamlDyKNpSj3jj+k4ojtUo
4 changed files with 18 additions and 6 deletions

View File

@ -1,5 +1,9 @@
all: osrm TOPS_data_process crashmaps
osrm: osrm-data osrm-containers osrm: osrm-data osrm-containers
crashmaps: schoolmaps_PDFs crashmaps_dynamic crashmaps_dynamic_milwaukee crash_data_summaries
TOPS_data_process: R/TOPS_data_process.Rmd TOPS_data_process: R/TOPS_data_process.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 = "./R/TOPS_data_process.Rmd", output_file = "./html/TOPS_data_process.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 = "./R/TOPS_data_process.Rmd", output_file = "./html/TOPS_data_process.html")'

View File

@ -118,16 +118,16 @@ if(str_to_lower(county_focus) == "all") {
# set which school types to generate figures for # set which school types to generate figures for
school_type_focus <- run_parameters$school_type_focus school_type_focus <- run_parameters$school_type_focus
if(str_to_lower(school_type_focus) == "all") { if(str_to_lower(school_type_focus) == "all") {
school_type_focus <- unique(WI_schools %>% filter(CTY_DIST %in% str_to_title(county_focus)) %>% pull(SCHOOLTYPE)) school_type_focus <- unique(WI_schools %>% pull(SCHOOLTYPE))
} }
# set which school types to generate figures for # set which school types to generate figures for
district_focus <- run_parameters$district_focus district_focus <- run_parameters$district_focus
if(str_to_lower(district_focus) == "all") { if(str_to_lower(district_focus) == "all") {
district_focus <- unique(WI_schools %>% filter(CTY_DIST %in% str_to_title(county_focus), SCHOOLTYPE %in% school_type_focus, !is.na(DISTRICT_NAME)) %>% pull(DISTRICT_NAME)) district_focus <- unique(WI_schools %>% pull(DISTRICT_NAME))
} }
school_number <- length(unique(WI_schools %>% filter(CTY_DIST %in% str_to_title(county_focus), school_number <- length(unique(WI_schools %>% filter(str_to_upper(CTY_DIST) %in% county_focus,
SCHOOLTYPE %in% school_type_focus, SCHOOLTYPE %in% school_type_focus,
DISTRICT_NAME %in% district_focus) %>% DISTRICT_NAME %in% district_focus) %>%
pull(district_school))) pull(district_school)))
@ -257,9 +257,12 @@ generate_school_maps <- function(district) {
message(paste("***", district, "School District |")) message(paste("***", district, "School District |"))
options(ggmap.file_drawer = paste0("basemaps/districts/", district)) options(ggmap.file_drawer = paste0("basemaps/districts/", district))
if(file.exists(paste0("basemaps/districts/", district, "/index.rds")) & !run_parameters$refresh_basemaps) {
readRDS(file_drawer("index.rds"))
} else {
dir.create(file_drawer(), recursive = TRUE, showWarnings = FALSE) dir.create(file_drawer(), recursive = TRUE, showWarnings = FALSE)
saveRDS(list(), file_drawer("index.rds")) saveRDS(list(), file_drawer("index.rds"))
readRDS(file_drawer("index.rds")) }
file_drawer("index.rds") file_drawer("index.rds")
for(school in WI_schools %>% for(school in WI_schools %>%
filter(DISTRICT_NAME %in% district, filter(DISTRICT_NAME %in% district,

View File

@ -2,3 +2,6 @@
* *
# Except this file # Except this file
!.gitignore !.gitignore
# Except the run_parameters template
!run_parameters_template.csv

View File

@ -0,0 +1,2 @@
county_focus,school_type_focus,district_focus,parallel,refresh_basemaps
ALL,ALL,ALL,TRUE,TRUE
1 county_focus school_type_focus district_focus parallel refresh_basemaps
2 ALL ALL ALL TRUE TRUE