diff --git a/app-profile.R b/app-profile.R new file mode 100644 index 0000000..4a51a8c --- /dev/null +++ b/app-profile.R @@ -0,0 +1,7 @@ +library(profvis) + +setwd("/home/dylan/Personal/Projects/Hurricane Normalization/R/dataScripts/restructured/app") + +profvis({ + rmarkdown::render("dashboard.Rmd") +}) diff --git a/queries.R b/queries.R index ba0917d..d2ce274 100644 --- a/queries.R +++ b/queries.R @@ -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)