modify views and tests

This commit is contained in:
2025-07-08 12:55:05 -04:00
parent 1597f850df
commit 6211983c7f
+38 -13
View File
@@ -49,16 +49,24 @@ view.hurdat_track <- tbl(con, "hurdat_track")
view.all_loss_storms <- tbl(con, "all_loss_storms") view.all_loss_storms <- tbl(con, "all_loss_storms")
view.all_loss_landfalls <- tbl(con, "all_loss_landfalls") view.all_loss_landfalls <- tbl(con, "all_loss_landfalls")
view.yearly_normalized_losses <- tbl(con, "yearly_normalized_losses") view.yearly_normalized_losses <- tbl(con, "yearly_normalized_losses")
view.county_population_housing <- tbl(con, "county_population_housing") view.simplified_county_geom <- tbl(con, "simplified_county_geom")
# test storm # test storm
storm <- list( #katrina <- list(
storm_basin = "AL", # storm_basin = "AL",
storm_year = 2005, # storm_year = 2005,
storm_name = "KATRINA", # storm_name = "KATRINA",
lf_type = "LF", # lf_type = "LF",
lf_id = 1 # lf_id = 1
) #)
#galveston <- list(
# storm_basin = "AL",
# storm_year = 1900,
# storm_name = "GALVESTON",
# lf_type = "LF",
# lf_id = 1
#)
# helper functions # helper functions
@@ -236,12 +244,9 @@ get_normalized_metric_growth <- function(storm, full_lf_id) {
) )
query <- normalized_metrics %>% query <- normalized_metrics %>%
inner_join( inner_join(public.counties, by = c("state_fips" = "statefp", "county_fips" = "countyfp")) %>%
public.counties,
by = c("state_fips" = "statefp", "county_fips" = "countyfp")
) %>%
mutate( mutate(
geom_wkt = sql("ST_AsText(ST_Transform(geom, 4326))") geom_wkt = sql("ST_AsText(ST_SimplifyPreserveTopology(ST_Transform(geom, 4326), .001))")
) %>% ) %>%
select( select(
state_fips, state_fips,
@@ -255,6 +260,26 @@ get_normalized_metric_growth <- function(storm, full_lf_id) {
) %>% ) %>%
arrange(state_fips, county_fips, year) arrange(state_fips, county_fips, year)
#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() result <- query %>% collect()
return(result) return(result)