From 89822c5c5cf666e0db445b0e1fd29be686838cd9 Mon Sep 17 00:00:00 2001 From: elmeraa <eazadpour@usgs.gov> Date: Wed, 20 Mar 2024 13:33:54 -0700 Subject: [PATCH] drop empty census vars and maps --- 2_process.R | 4 +--- 3_visualize.R | 44 ------------------------------------ 3_visualize/src/plot_utils.R | 7 +++--- 3 files changed, 4 insertions(+), 51 deletions(-) diff --git a/2_process.R b/2_process.R index c615d5f..27ac12f 100644 --- a/2_process.R +++ b/2_process.R @@ -87,10 +87,8 @@ tar_target(p2_census_acs5sub_age_data, iteration = "list"), # income related variables # S1901_C01_014 = Estimate!!Households!!PERCENT ALLOCATED!!Household income in the past 12 months -# S1901_C01_015 = Estimate!!Households!!PERCENT ALLOCATED!!Family income in the past 12 months -# S1901_C01_016 = Estimate!!Households!!PERCENT ALLOCATED!!Nonfamily income in the past 12 months tar_target(p2_census_acs5sub_income_layers, - c("S1901_C01_014", "S1901_C01_015", "S1901_C01_016")), + c("S1901_C01_014")), tar_target(p2_census_acs5sub_income_data, get_census_data(geography = 'county', variable = p2_census_acs5sub_income_layers, states = p1_census_states, year = 2022, proj = p1_proj, diff --git a/3_visualize.R b/3_visualize.R index 66ce1ca..a00a159 100644 --- a/3_visualize.R +++ b/3_visualize.R @@ -264,50 +264,6 @@ p3_targets <- list( ), format = "file" ), - tar_target( - # empty map - p3_perc_family_income_map_png, - plot_census_map( - census_data = p2_census_acs5sub_income_data[[2]], - percent_leg = TRUE, - var = 'percent', - conus_sf = p1_conus_sf, - outfile_path = "3_visualize/out/perc_family_income_2022.png", - pal = "OrRd", - leg_title = "Percent allocated\family income\nin the past 12 months, 2022", - width = 6, - height = 4, - dpi = 300, - counties_outline_col = "grey80", - conus_outline_col = 'grey50', - bg_col = "white", - load_font = 'Source Sans Pro', - font_size = 10 - ), - format = "file" - ), - tar_target( - # empty map - p3_perc_nonfamily_income_map_png, - plot_census_map( - census_data = p2_census_acs5sub_income_data[[3]], - percent_leg = TRUE, - var = 'percent', - conus_sf = p1_conus_sf, - outfile_path = "3_visualize/out/perc_nonfamily_income_2022.png", - pal = "OrRd", - leg_title = "Percent allocated\nonfamily income\nin the past 12 months, 2022", - width = 6, - height = 4, - dpi = 300, - counties_outline_col = "grey80", - conus_outline_col = 'grey50', - bg_col = "white", - load_font = 'Source Sans Pro', - font_size = 10 - ), - format = "file" - ), # education related map tar_target( p3_tot_18_24_highschool_education_map_png, diff --git a/3_visualize/src/plot_utils.R b/3_visualize/src/plot_utils.R index 92d4085..f8f274a 100644 --- a/3_visualize/src/plot_utils.R +++ b/3_visualize/src/plot_utils.R @@ -13,8 +13,7 @@ #' @param bg_col, assign background color for maps #' @param load_font, assign font name #' @param percent_leg if else statement where if TRUE, apply 0-100 legend, otherwise retain 0 - max of variable name -plot_census_map <- function(census_data, conus_sf, pal, leg_title, outfile_path, width, height, dpi, - counties_outline_col, conus_outline_col, bg_col, load_font, font_size, var, percent_leg){ +plot_census_map <- function(census_data, conus_sf, pal, leg_title, outfile_path, width, height, dpi, counties_outline_col, conus_outline_col, bg_col, load_font, font_size, var, percent_leg){ font_legend <- load_font font_add_google(font_legend) @@ -40,7 +39,7 @@ plot_census_map <- function(census_data, conus_sf, pal, leg_title, outfile_path, position = "bottom", barwidth = 20, barheight = 1 - ) + )) if (percent_leg == FALSE) { census_map <- census_map + @@ -64,4 +63,4 @@ plot_census_map <- function(census_data, conus_sf, pal, leg_title, outfile_path, ggsave(outfile_path, census_map, width = width, height = height, dpi = dpi, bg = bg_col) return(outfile_path) -} +} \ No newline at end of file -- GitLab