add proxy map updates

This commit is contained in:
2025-06-10 15:32:04 -04:00
parent d653271142
commit 49ef7919bc
2 changed files with 193 additions and 77 deletions
+69 -69
View File
@@ -248,75 +248,75 @@ get_hurdat_track <- function(storm) {
}
# returns normalized population and housing growth by county with geometry
#get_normalized_metric_growth <- function(storm, full_lf_id) {
# lf_id_parts <- split_full_lf_id(full_lf_id)
#
# affected_counties <- gis.affected_area_landfalls %>%
# filter(
# storm_basin == storm$storm_basin,
# storm_year == storm$storm_year,
# storm_name == storm$storm_name,
# lf_type == lf_id_parts$lf_type,
# lf_id == lf_id_parts$lf_id
# ) %>%
# select(state_fips, county_fips)
#
# baseline_metrics <- metrics.pop_and_housing %>%
# filter(
# year == storm$storm_year
# ) %>%
# inner_join(affected_counties, by = c("state_fips", "county_fips")) %>%
# select(
# state_fips,
# county_fips,
# baseline_population = population,
# baseline_housing = housing_units
# )
#
# normalized_metrics <- metrics.pop_and_housing %>%
# filter(
# year >= storm$storm_year
# ) %>%
# inner_join(affected_counties, by = c("state_fips", "county_fips")) %>%
# inner_join(baseline_metrics, by = c("state_fips", "county_fips")) %>%
# mutate(
# normalized_population = as.numeric(population) / as.numeric(baseline_population),
# normalized_housing = as.numeric(housing_units) / as.numeric(baseline_housing)
# ) %>%
# select(
# state_fips,
# county_fips,
# year,
# population,
# housing_units,
# normalized_population,
# normalized_housing
# )
#
# query <- normalized_metrics %>%
# inner_join(
# public.counties,
# by = c("state_fips" = "statefp", "county_fips" = "countyfp")
# ) %>%
# mutate(
# geom_wkt = sql("ST_AsText(ST_Transform(geom, 4326))")
# ) %>%
# select(
# state_fips,
# county_fips,
# year,
# population,
# housing_units,
# normalized_population,
# normalized_housing,
# geom_wkt
# ) %>%
# arrange(state_fips, county_fips, year)
#
# result <- query %>% collect()
#
# return(result)
#}
get_normalized_metric_growth <- function(storm, full_lf_id) {
lf_id_parts <- split_full_lf_id(full_lf_id)
affected_counties <- gis.affected_area_landfalls %>%
filter(
storm_basin == storm$storm_basin,
storm_year == storm$storm_year,
storm_name == storm$storm_name,
lf_type == lf_id_parts$lf_type,
lf_id == lf_id_parts$lf_id
) %>%
select(state_fips, county_fips)
baseline_metrics <- metrics.pop_and_housing %>%
filter(
year == storm$storm_year
) %>%
inner_join(affected_counties, by = c("state_fips", "county_fips")) %>%
select(
state_fips,
county_fips,
baseline_population = population,
baseline_housing = housing_units
)
normalized_metrics <- metrics.pop_and_housing %>%
filter(
year >= storm$storm_year
) %>%
inner_join(affected_counties, by = c("state_fips", "county_fips")) %>%
inner_join(baseline_metrics, by = c("state_fips", "county_fips")) %>%
mutate(
normalized_population = as.numeric(population) / as.numeric(baseline_population),
normalized_housing = as.numeric(housing_units) / as.numeric(baseline_housing)
) %>%
select(
state_fips,
county_fips,
year,
population,
housing_units,
normalized_population,
normalized_housing
)
query <- normalized_metrics %>%
inner_join(
public.counties,
by = c("state_fips" = "statefp", "county_fips" = "countyfp")
) %>%
mutate(
geom_wkt = sql("ST_AsText(ST_Transform(geom, 4326))")
) %>%
select(
state_fips,
county_fips,
year,
population,
housing_units,
normalized_population,
normalized_housing,
geom_wkt
) %>%
arrange(state_fips, county_fips, year)
result <- query %>% collect()
return(result)
}
# test functions