update growth map to use indirect landfall states

This commit is contained in:
2025-12-24 17:04:39 -05:00
parent 704d475139
commit 4f94249b23
+68 -19
View File
@@ -30,6 +30,8 @@ fips.counties <- tbl(con, I("fips.counties"))
fips.states <- tbl(con, I("fips.states")) fips.states <- tbl(con, I("fips.states"))
gis.affected_area_landfalls <- tbl(con, I("gis.affected_area_landfalls")) gis.affected_area_landfalls <- tbl(con, I("gis.affected_area_landfalls"))
gis.indirect_landfalls <- tbl(con, I("gis.indirect_landfalls"))
gis.us_states_boundary <- tbl(con, I("gis.us_states_boundary"))
hurdat.best_track <- tbl(con, I("hurdat.best_track")) hurdat.best_track <- tbl(con, I("hurdat.best_track"))
hurdat.hurdat_storms <- tbl(con, I("hurdat.hurdat_storms")) hurdat.hurdat_storms <- tbl(con, I("hurdat.hurdat_storms"))
@@ -54,6 +56,7 @@ view.all_lf_type_landfalls <- tbl(con, "all_lf_type_landfalls")
view.lf_id_location <- tbl(con, "lf_id_location") view.lf_id_location <- tbl(con, "lf_id_location")
view.lf_landfall_gis <- tbl(con, "lf_landfall_gis") view.lf_landfall_gis <- tbl(con, "lf_landfall_gis")
view.best_track_summary <- tbl(con, "best_track_summary") view.best_track_summary <- tbl(con, "best_track_summary")
view.yearly_state_metrics <- tbl(con, "yearly_state_metrics")
#qry <- econ.storm_base_loss %>% #qry <- econ.storm_base_loss %>%
# left_join(view.hurdat_track, by = c("storm_basin", "storm_year", "storm_name")) # left_join(view.hurdat_track, by = c("storm_basin", "storm_year", "storm_name"))
@@ -417,6 +420,7 @@ get_hurdat_track <- function(storm) {
get_normalized_metric_growth <- function(storm, full_lf_id) { get_normalized_metric_growth <- function(storm, full_lf_id) {
lf_id_parts <- split_full_lf_id(full_lf_id) lf_id_parts <- split_full_lf_id(full_lf_id)
if (lf_id_parts$lf_type == 'LF') {
affected_counties <- gis.affected_area_landfalls %>% affected_counties <- gis.affected_area_landfalls %>%
filter( filter(
storm_basin == storm$storm_basin, storm_basin == storm$storm_basin,
@@ -482,26 +486,71 @@ get_normalized_metric_growth <- function(storm, full_lf_id) {
geom_wkt geom_wkt
) %>% ) %>%
arrange(state_fips, county_fips, year) arrange(state_fips, county_fips, year)
} else {
affected_state <- gis.indirect_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
)
#query <- normalized_metrics %>% baseline_metrics <- view.yearly_state_metrics %>%
# inner_join( filter(year == storm$storm_year) %>%
# public.counties, inner_join(affected_state, by = "state_fips") %>%
# by = c("state_fips" = "statefp", "county_fips" = "countyfp") select(
# ) %>% state_fips,
# mutate( baseline_population = state_population,
# geom_wkt = sql("ST_AsText(ST_Transform(geom, 4326))") baseline_housing = state_housing_units
# ) %>% )
# select(
# state_fips, normalized_metrics <- view.yearly_state_metrics %>%
# county_fips, filter(
# year, year >= storm$storm_year
# population, ) %>%
# housing_units, inner_join(affected_state, by = "state_fips") %>%
# normalized_population, inner_join(baseline_metrics, by = "state_fips") %>%
# normalized_housing, mutate(
# geom_wkt normalized_population = as.numeric(state_population) /
# ) %>% as.numeric(baseline_population),
# arrange(state_fips, county_fips, year) normalized_housing = as.numeric(state_housing_units) /
as.numeric(baseline_housing)
) %>%
select(
state_fips,
year,
population = state_population,
housing_units = state_housing_units,
normalized_population,
normalized_housing
)
query <- normalized_metrics %>%
inner_join(
gis.us_states_boundary %>%
rename(state_fips = statefp),
by = "state_fips"
) %>%
mutate(
geom_wkt = sql(
"ST_AsText(ST_SimplifyPreserveTopology(ST_Transform(wkb_geometry, 4326), .001))"
)
) %>%
select(
state_fips,
year,
population,
housing_units,
normalized_population,
normalized_housing,
geom_wkt
) %>%
arrange(state_fips, year)
}
result <- query %>% collect() result <- query %>% collect()