From 248665fdf67baaef5a3d62ebddcb6fb1dcf42b66 Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Sun, 3 Aug 2025 00:46:45 -0400 Subject: [PATCH] add data population to calc --- dashboard.Rmd | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ queries.R | 26 +++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/dashboard.Rmd b/dashboard.Rmd index 420221c..27b1322 100644 --- a/dashboard.Rmd +++ b/dashboard.Rmd @@ -1032,7 +1032,56 @@ calculator_storm_selection <- reactiveValues( full_lf_id = NULL, ) +observeEvent(input$impact_populate_storm, { + calculator_storm_selection$storm_basin = input$impact_storm_basin + calculator_storm_selection$storm_year = input$impact_storm_year + calculator_storm_selection$storm_name = input$impact_storm_name + calculator_storm_selection$full_lf_id = input$impact_storm_full_lf_id + calculator_storm_details <- get_lf_type_factors(calculator_storm_selection) + + updateTextInput( + session, + "impact_lat", + value = calculator_storm_details$lat + ) + + updateTextInput( + session, + "impact_lon", + value = calculator_storm_details$lon + ) + + updateTextInput( + session, + "impact_rmw", + value = calculator_storm_details$rmw + ) + + updateSliderInput( + session, + "impact_rmw_slider", + value = calculator_storm_details$rmw + ) + + updateTextInput( + session, + "impact_base_year", + value = calculator_storm_details$storm_year + ) + + updateTextInput( + session, + "impact_ref_year", + value = "2024" + ) + + updateTextInput( + session, + "impact_base_damage", + value = calculator_storm_details$mwr + ) +}) ``` Column {data-width=700} diff --git a/queries.R b/queries.R index 0932b3a..100f56a 100644 --- a/queries.R +++ b/queries.R @@ -58,7 +58,7 @@ view.all_conus_landfalls <- tbl(con, "all_conus_landfalls") view.hurdat_ids <- tbl(con, "hurdat_ids") view.all_lf_type_landfalls <- tbl(con, "all_lf_type_landfalls") view.lf_id_location <- tbl(con, "lf_id_location") - +view.lf_landfall_gis <- tbl(con, "lf_landfall_gis") #qry <- econ.storm_base_loss %>% # left_join(view.hurdat_track, by = c("storm_basin", "storm_year", "storm_name")) @@ -456,3 +456,27 @@ get_all_lf_type_landfalls <- function() { return(result) } + +# returns all storms and factors needed to normalize a lf type landfall +get_all_lf_type_factors <- function() { + query <- view.lf_landfall_gis + + result <- query %>% collect() + + return(result) +} + +# returns one storm and factors needed to normalize a lf type landfall +get_lf_type_factors <- function(storm) { + query <- view.lf_landfall_gis %>% + filter( + storm_basin == storm$storm_basin, + storm_year == storm$storm_year, + storm_name == storm$storm_name, + full_lf_id == storm$full_lf_id + ) + + result <- query %>% collect() + + return(result) +}