mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
Merge branch 'db_queries'
This commit is contained in:
@@ -49,16 +49,24 @@ view.hurdat_track <- tbl(con, "hurdat_track")
|
||||
view.all_loss_storms <- tbl(con, "all_loss_storms")
|
||||
view.all_loss_landfalls <- tbl(con, "all_loss_landfalls")
|
||||
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
|
||||
storm <- list(
|
||||
storm_basin = "AL",
|
||||
storm_year = 2005,
|
||||
storm_name = "KATRINA",
|
||||
lf_type = "LF",
|
||||
lf_id = 1
|
||||
)
|
||||
#katrina <- list(
|
||||
# storm_basin = "AL",
|
||||
# storm_year = 2005,
|
||||
# storm_name = "KATRINA",
|
||||
# lf_type = "LF",
|
||||
# lf_id = 1
|
||||
#)
|
||||
|
||||
#galveston <- list(
|
||||
# storm_basin = "AL",
|
||||
# storm_year = 1900,
|
||||
# storm_name = "GALVESTON",
|
||||
# lf_type = "LF",
|
||||
# lf_id = 1
|
||||
#)
|
||||
|
||||
# helper functions
|
||||
|
||||
@@ -238,12 +246,9 @@ get_normalized_metric_growth <- function(storm, full_lf_id) {
|
||||
)
|
||||
|
||||
query <- normalized_metrics %>%
|
||||
inner_join(
|
||||
public.counties,
|
||||
by = c("state_fips" = "statefp", "county_fips" = "countyfp")
|
||||
) %>%
|
||||
inner_join(public.counties, by = c("state_fips" = "statefp", "county_fips" = "countyfp")) %>%
|
||||
mutate(
|
||||
geom_wkt = sql("ST_AsText(ST_Transform(geom, 4326))")
|
||||
geom_wkt = sql("ST_AsText(ST_SimplifyPreserveTopology(ST_Transform(geom, 4326), .001))")
|
||||
) %>%
|
||||
select(
|
||||
state_fips,
|
||||
@@ -257,6 +262,26 @@ get_normalized_metric_growth <- function(storm, full_lf_id) {
|
||||
) %>%
|
||||
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()
|
||||
|
||||
return(result)
|
||||
|
||||
Reference in New Issue
Block a user