Skip to content

Commit

Permalink
Merge branch 'add-lang' into 'main'
Browse files Browse the repository at this point in the history
Add Spanish translation

See merge request wma/vizlab/vulnerability-indicators!66
  • Loading branch information
cnell-usgs committed Sep 10, 2024
2 parents 9524d14 + 7816330 commit c834bab
Show file tree
Hide file tree
Showing 52 changed files with 3,276 additions and 637 deletions.
14 changes: 7 additions & 7 deletions 0_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ p0_targets <- list(
# Create a tibble to define color palette for dimensions
p0_viz_config_pal,
tibble(
demographic_characteristics = "#092836",
exposure = "#FFA601",
health = "#EE5775",
land_tenure = "#1C695E",
living_conditions = "#7A5195",
risk_perception = "#FF774A",
socioeconomic_status = "#2A468F"
demographic_characteristics = "#092734",
exposure = "#FFA600",
health = "#4B1B1B",
land_tenure = "#1B695F",
living_conditions = "#4BAFA3",
risk_perception = "#365EB5",
socioeconomic_status = "#FF734D"
)
)
)
75 changes: 54 additions & 21 deletions 2_process.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ p2_targets <- list(
# distinct(determinant, .keep_all = TRUE) |>
readr::write_csv('public/determinant_uncertainty.csv')
),
tar_target(p2_unc_determinant_json,
read_csv(p2_unc_agg_summary_csv) |>
toJSON(pretty = TRUE) |>
write("public/determinant_uncertainty.json")
),
tar_target(`p2_unc_agg_summary_ind_csv`,
p2_unc_agg_ind_summary |>
left_join(p2_top_trend_ind_stats) |>
Expand Down Expand Up @@ -103,9 +108,13 @@ tar_target(`p2_unc_agg_summary_ind_csv`,
"B03001_003", "B01001_002", "B01001_026")
),
tar_target(p2_census_acs5_data,
get_census_data(geography = 'county', variable = p2_census_acs5_layers,
states = p1_census_states, year = 2022, proj = p1_proj,
survey_var = "acs5", percent_rename = FALSE),
get_census_data(geography = 'county',
variable = p2_census_acs5_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = FALSE),
pattern = map(p2_census_acs5_layers),
iteration = "list"
),
Expand All @@ -131,19 +140,27 @@ tar_target(`p2_unc_agg_summary_ind_csv`,
tar_target(p2_census_acs5sub_age_layers,
c("S0101_C02_022", "S0101_C02_023", "S0101_C02_024", "S0101_C02_028")),
tar_target(p2_census_acs5sub_age_data,
get_census_data(geography = 'county', variable = p2_census_acs5sub_age_layers,
states = p1_census_states, year = 2022, proj = p1_proj,
survey_var = "acs5", percent_rename = TRUE),
get_census_data(geography = 'county',
variable = p2_census_acs5sub_age_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = TRUE),
pattern = map(p2_census_acs5sub_age_layers),
iteration = "list"),
# income related variables
# S1901_C01_014 = Estimate!!Households!!PERCENT ALLOCATED!!Household income in the past 12 months
tar_target(p2_census_acs5sub_income_layers,
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,
survey_var = "acs5", percent_rename = TRUE),
get_census_data(geography = 'county',
variable = p2_census_acs5sub_income_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = TRUE),
pattern = map(p2_census_acs5sub_income_layers),
iteration = "list"),
# education related variables
Expand All @@ -152,9 +169,13 @@ tar_target(p2_census_acs5sub_income_data,
tar_target(p2_census_acs5sub_education_layers,
c("S1501_C01_003", "S1501_C01_009")),
tar_target(p2_census_acs5sub_education_data,
get_census_data(geography = 'county', variable = p2_census_acs5sub_education_layers,
states = p1_census_states, year = 2022, proj = p1_proj,
survey_var = "acs5", percent_rename = FALSE),
get_census_data(geography = 'county',
variable = p2_census_acs5sub_education_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = FALSE),
pattern = map(p2_census_acs5sub_education_layers),
iteration = "list"),

Expand All @@ -164,9 +185,13 @@ tar_target(p2_census_acs5sub_education_data,
tar_target(p2_census_acs5_household_layers,
c("B25010_001", "B25064_001")),
tar_target(p2_census_acs5sub_household_data,
get_census_data(geography = 'county', variable = p2_census_acs5_household_layers,
states = p1_census_states, year = 2022, proj = p1_proj,
survey_var = "acs5", percent_rename = FALSE),
get_census_data(geography = 'county',
variable = p2_census_acs5_household_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = FALSE),
pattern = map(p2_census_acs5_household_layers),
iteration = "list"),
# percent households variable
Expand All @@ -193,9 +218,13 @@ tar_target(p2_census_acs5profile_household_sf,
tar_target(p2_census_acs5_income_by_race_layers,
c("B19013A_001", "B19013B_001", "B19013C_001", "B19013D_001", "B19013E_001", "B19013I_001")),
tar_target(p2_census_acs5sub_income_by_race_data,
get_census_data(geography = 'county', variable = p2_census_acs5_income_by_race_layers,
states = p1_census_states, year = 2022, proj = p1_proj,
survey_var = "acs5", percent_rename = FALSE),
get_census_data(geography = 'county',
variable = p2_census_acs5_income_by_race_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = FALSE),
pattern = map(p2_census_acs5_income_by_race_layers),
iteration = "list"),
# Disability status
Expand All @@ -204,9 +233,13 @@ tar_target(p2_census_acs5sub_income_by_race_data,
tar_target(p2_census_acs5_disability_layers,
c("S1810_C03_001", "S1810_C02_001")),
tar_target(p2_census_acs5sub_disability_data,
get_census_data(geography = 'county', variable = p2_census_acs5_disability_layers,
states = p1_census_states, year = 2022, proj = p1_proj,
survey_var = "acs5", percent_rename = FALSE),
get_census_data(geography = 'county',
variable = p2_census_acs5_disability_layers,
states = p1_census_states,
year = 2022,
proj = p1_proj,
survey_var = "acs5",
percent_rename = FALSE),
pattern = map(p2_census_acs5_disability_layers),
iteration = "list")
)
148 changes: 133 additions & 15 deletions 3_visualize.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@ source('3_visualize/src/plot_utils.R')
# For case studies approach: select one demographic characteristic (hispanic/latino),
p3_targets <- list(
tar_target(
p3_med_income_png,
p3_med_income_png_en,
plot_census_map(
census_data = p2_perc_census_acs5_layers_sf[[2]],
lim_vals = c(0, 155000),
percent_leg = FALSE,
dollar_leg = TRUE,
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/med_income_census_2022.png",
outfile_path = "3_visualize/out/med_income_census_2022_en.png",
leg_title = "Median household income, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$socioeconomic_status,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1
barheight = 1,
low_ramp_col = "#fef1f1"
),
format = "file"
),
tar_target(
p3_perc_latino_png,
p3_perc_latino_png_en,
plot_census_map(
census_data = p2_perc_census_acs5_layers_sf[[4]],
percent_leg = TRUE,
Expand All @@ -34,62 +35,65 @@ p3_targets <- list(
break_vals = c(0, 25, 50, 75, 100),
var = 'percent',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/perc_hispanic_census_2022.png",
outfile_path = "3_visualize/out/perc_hispanic_census_2022_en.png",
leg_title = "Percent Hispanic, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$demographic_characteristics,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1
barheight = 1,
low_ramp_col = "#eef0ff"
),
format = "file"
),
tar_target(
p3_avg_household_size_png,
p3_avg_household_size_png_en,
plot_census_map(
census_data = p2_census_acs5sub_household_data[[1]],
percent_leg = FALSE,
dollar_leg = FALSE,
lim_vals = c(1, 5),
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/avg_household_size_2022.png",
outfile_path = "3_visualize/out/avg_household_size_2022_en.png",
leg_title = "Average household size, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$demographic_characteristics,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1
barheight = 1,
low_ramp_col = "#eef0ff"
),
format = "file"
),
tar_target(
p3_median_rent_png,
p3_median_rent_png_en,
plot_census_map(
census_data = p2_census_acs5sub_household_data[[2]],
percent_leg = FALSE,
dollar_leg = TRUE,
lim_vals = c(0, 3000),
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/median_rent_2022.png",
outfile_path = "3_visualize/out/median_rent_2022_en.png",
leg_title = "Median gross rent, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$land_tenure,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1
barheight = 1,
low_ramp_col = "#ebfaf8"
),
format = "file"
),
tar_target(
p3_perc_disable_png,
p3_perc_disable_png_en,
plot_census_map(
census_data = p2_census_acs5sub_disability_data[[1]],
percent_leg = TRUE,
Expand All @@ -98,16 +102,130 @@ p3_targets <- list(
break_vals = c(0, 10, 20, 30, 40, 50),
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/perc_disabled_census_2022.png",
outfile_path = "3_visualize/out/perc_disabled_census_2022_en.png",
leg_title = "Percent disabled, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$demographic_characteristics,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1
barheight = 1,
low_ramp_col = "#eef0ff"
),
format = "file"
),
# Spanish version's of maps -----------------------------------------------
tar_target(
p3_med_income_png_es,
plot_census_map(
census_data = p2_perc_census_acs5_layers_sf[[2]],
lim_vals = c(0, 155000),
percent_leg = FALSE,
dollar_leg = TRUE,
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/med_income_census_2022_es.png",
leg_title = "Media de ingresos por hogar, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$socioeconomic_status,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1,
low_ramp_col = "#fef1f1"
),
format = "file"
),
tar_target(
p3_perc_latino_png_es,
plot_census_map(
census_data = p2_perc_census_acs5_layers_sf[[4]],
percent_leg = TRUE,
dollar_leg = FALSE,
lim_vals = c(0, 100),
break_vals = c(0, 25, 50, 75, 100),
var = 'percent',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/perc_hispanic_census_2022_es.png",
leg_title = "Porcentaje de Hispanos, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$demographic_characteristics,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1,
low_ramp_col = "#eef0ff"
),
format = "file"
),
tar_target(
p3_avg_household_size_png_es,
plot_census_map(
census_data = p2_census_acs5sub_household_data[[1]],
percent_leg = FALSE,
dollar_leg = FALSE,
lim_vals = c(1, 5),
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/avg_household_size_2022_es.png",
leg_title = "Tamaño promedio de los hogares, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$demographic_characteristics,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1,
low_ramp_col = "#eef0ff"
),
format = "file"
),
tar_target(
p3_median_rent_png_es,
plot_census_map(
census_data = p2_census_acs5sub_household_data[[2]],
percent_leg = FALSE,
dollar_leg = TRUE,
lim_vals = c(0, 3000),
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/median_rent_2022_es.png",
leg_title = "Alquiler bruto medio, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$land_tenure,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1,
low_ramp_col = "#ebfaf8"
),
format = "file"
),
tar_target(
p3_perc_disable_png_es,
plot_census_map(
census_data = p2_census_acs5sub_disability_data[[1]],
percent_leg = TRUE,
dollar_leg = FALSE,
lim_vals = c(0, 50),
break_vals = c(0, 10, 20, 30, 40, 50),
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/perc_disabled_census_2022_es.png",
leg_title = "Porcentaje de discapacitados, 2022",
viz_config_df = p0_viz_config_df,
viz_config_pal = p0_viz_config_pal$demographic_characteristics,
width = p0_viz_config_df$width_desktop,
height = p0_viz_config_df$height_desktop,
font_size = p0_viz_config_df$font_size_desktop,
barwidth = 20,
barheight = 1,
low_ramp_col = "#eef0ff"
),
format = "file"
)
)
Loading

0 comments on commit c834bab

Please sign in to comment.