mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
add lfs and lat/lon to calc
This commit is contained in:
+96
-48
@@ -1022,7 +1022,20 @@ Storm Fatalities {data-navmenu="Storm Details"}
|
|||||||
Normalization Calculator {data-navmenu="Compute"}
|
Normalization Calculator {data-navmenu="Compute"}
|
||||||
===
|
===
|
||||||
|
|
||||||
Column {data-width=700 .tabset}
|
```{r}
|
||||||
|
# Calculator - Setup Code
|
||||||
|
|
||||||
|
calculator_storm_selection <- reactiveValues(
|
||||||
|
storm_year = NULL,
|
||||||
|
storm_name = NULL,
|
||||||
|
storm_basin = NULL,
|
||||||
|
full_lf_id = NULL,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Column {data-width=700}
|
||||||
---
|
---
|
||||||
|
|
||||||
### Impact Map {.no-padding}
|
### Impact Map {.no-padding}
|
||||||
@@ -1031,35 +1044,30 @@ Column {data-width=700 .tabset}
|
|||||||
|
|
||||||
output$impact_analysis_map <- renderLeaflet({
|
output$impact_analysis_map <- renderLeaflet({
|
||||||
leaflet() %>%
|
leaflet() %>%
|
||||||
addProviderTiles("Stadia.AlidadeSmooth") %>%
|
addProviderTiles("Stadia.AlidadeSmooth") #%>%
|
||||||
setView(lng = -80.3, lat = 25.6, zoom = 10) %>%
|
#setView(lng = -80.3, lat = 25.6, zoom = 10) %>%
|
||||||
addCircles(
|
#addCircles(
|
||||||
lng = -80.3,
|
# lng = -80.3,
|
||||||
lat = 25.6,
|
# lat = 25.6,
|
||||||
radius = 37040,
|
# radius = 37040,
|
||||||
color = "blue",
|
# color = "blue",
|
||||||
weight = 2,
|
# weight = 2,
|
||||||
opacity = 0.3
|
# opacity = 0.3
|
||||||
) %>%
|
#) %>%
|
||||||
addCircleMarkers(
|
#addCircleMarkers(
|
||||||
lng = -80.3,
|
# lng = -80.3,
|
||||||
lat = 25.6,
|
# lat = 25.6,
|
||||||
radius = 5,
|
# radius = 5,
|
||||||
weight = 0,
|
# weight = 0,
|
||||||
color = "blue",
|
# color = "blue",
|
||||||
fillColor = "blue",
|
# fillColor = "blue",
|
||||||
fillOpacity = 0.6
|
# fillOpacity = 0.6
|
||||||
)
|
#)
|
||||||
})
|
})
|
||||||
|
|
||||||
leafletOutput("impact_analysis_map", height = "100%")
|
leafletOutput("impact_analysis_map", height = "100%")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Impact Data {.no-padding}
|
|
||||||
```{r}
|
|
||||||
# Calculator - Impact Data
|
|
||||||
```
|
|
||||||
|
|
||||||
Column {data-width=300}
|
Column {data-width=300}
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -1067,18 +1075,7 @@ Column {data-width=300}
|
|||||||
```{r}
|
```{r}
|
||||||
# Calculator - Input
|
# Calculator - Input
|
||||||
# TODO: add data population and compute
|
# TODO: add data population and compute
|
||||||
#observeEvent(input$stormYear, {
|
|
||||||
# stormsByChosenYear <- loss_storms[loss_storms$storm_year == input$stormYear, ]
|
|
||||||
#
|
|
||||||
# stormsByYear <- loss_storms %>% filter(storm_year == input$stormYear)
|
|
||||||
#
|
|
||||||
# updateSelectInput(
|
|
||||||
# session,
|
|
||||||
# "stormName",
|
|
||||||
# choices = stormsByYear$storm_name,
|
|
||||||
# selected = NULL
|
|
||||||
# )
|
|
||||||
#})
|
|
||||||
observeEvent(input$impact_storm_year, {
|
observeEvent(input$impact_storm_year, {
|
||||||
stormsByChosenYear <- all_lf_type_storms[all_lf_type_storms$storm_year == input$impact_storm_year, ]
|
stormsByChosenYear <- all_lf_type_storms[all_lf_type_storms$storm_year == input$impact_storm_year, ]
|
||||||
|
|
||||||
@@ -1092,41 +1089,92 @@ observeEvent(input$impact_storm_year, {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
observeEvent(input$impact_storm_name, {
|
||||||
|
uniqueLfs <- all_lf_type_storms %>%
|
||||||
|
filter(
|
||||||
|
storm_basin == input$impact_storm_basin,
|
||||||
|
storm_year == input$impact_storm_year,
|
||||||
|
storm_name == input$impact_storm_name
|
||||||
|
)
|
||||||
|
|
||||||
|
updateSelectInput(
|
||||||
|
session,
|
||||||
|
"impact_storm_full_lf_id",
|
||||||
|
choices = uniqueLfs$full_lf_id
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
observe({
|
||||||
|
req(
|
||||||
|
input$impact_lat,
|
||||||
|
input$impact_lon
|
||||||
|
)
|
||||||
|
|
||||||
|
new_lat <- as.numeric(input$impact_lat)
|
||||||
|
new_lon <- as.numeric(input$impact_lon)
|
||||||
|
|
||||||
|
if(new_lat >= -90 & new_lat <= 90 & new_lon >= -180 & new_lon <= 180) {
|
||||||
|
leafletProxy("impact_analysis_map") %>%
|
||||||
|
clearShapes() %>%
|
||||||
|
clearMarkers() %>%
|
||||||
|
addCircleMarkers(
|
||||||
|
lng = new_lon,
|
||||||
|
lat = new_lat,
|
||||||
|
radius = 2,
|
||||||
|
weight = 0,
|
||||||
|
color = "blue",
|
||||||
|
fillColor = "blue",
|
||||||
|
fillOpacity = 0.5
|
||||||
|
) %>%
|
||||||
|
addCircles(
|
||||||
|
lng = new_lon,
|
||||||
|
lat = new_lat,
|
||||||
|
radius = 18000,
|
||||||
|
weight = 1,
|
||||||
|
color = "blue",
|
||||||
|
fillColor = "blue",
|
||||||
|
fillOpacity = 0.05
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
div(
|
div(
|
||||||
h6("Storm Selector"),
|
h6("Storm Selector"),
|
||||||
|
|
||||||
|
fluidRow(
|
||||||
|
column(
|
||||||
|
6,
|
||||||
selectInput(
|
selectInput(
|
||||||
"impact_storm_basin",
|
"impact_storm_basin",
|
||||||
label = NULL,
|
label = NULL,
|
||||||
choices = "AL",
|
choices = "AL",
|
||||||
width = "100%"
|
width = "100%"
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
column(
|
||||||
|
6,
|
||||||
selectInput(
|
selectInput(
|
||||||
"impact_storm_year",
|
"impact_storm_year",
|
||||||
label = NULL,
|
label = NULL,
|
||||||
choices = all_lf_type_storms$storm_year,
|
choices = all_lf_type_storms$storm_year,
|
||||||
width = "100%"
|
width = "100%"
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
fluidRow(
|
||||||
|
column(
|
||||||
|
6,
|
||||||
selectInput(
|
selectInput(
|
||||||
"impact_storm_name",
|
"impact_storm_name",
|
||||||
label = NULL,
|
label = NULL,
|
||||||
choices = NULL,
|
choices = NULL,
|
||||||
width = "100%"
|
width = "100%"
|
||||||
),
|
),
|
||||||
|
|
||||||
fluidRow(
|
|
||||||
column(
|
|
||||||
6,
|
|
||||||
selectInput(
|
|
||||||
"impact_storm_lf_type",
|
|
||||||
label = NULL,
|
|
||||||
choices = "LF",
|
|
||||||
width = "100%"
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
column(
|
column(
|
||||||
6,
|
6,
|
||||||
selectInput(
|
selectInput(
|
||||||
"impact_storm_lf_id",
|
"impact_storm_full_lf_id",
|
||||||
label = NULL,
|
label = NULL,
|
||||||
choices = "1",
|
choices = "1",
|
||||||
width = "100%"
|
width = "100%"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ view.all_loss_storms_tracks <- tbl(con, "all_loss_storms_tracks")
|
|||||||
view.all_conus_landfalls <- tbl(con, "all_conus_landfalls")
|
view.all_conus_landfalls <- tbl(con, "all_conus_landfalls")
|
||||||
view.hurdat_ids <- tbl(con, "hurdat_ids")
|
view.hurdat_ids <- tbl(con, "hurdat_ids")
|
||||||
view.all_lf_type_landfalls <- tbl(con, "all_lf_type_landfalls")
|
view.all_lf_type_landfalls <- tbl(con, "all_lf_type_landfalls")
|
||||||
|
view.lf_id_location <- tbl(con, "lf_id_location")
|
||||||
|
|
||||||
#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"))
|
||||||
@@ -449,7 +450,7 @@ get_normalized_metric_growth <- function(storm, full_lf_id) {
|
|||||||
|
|
||||||
# returns all lf type landfalls
|
# returns all lf type landfalls
|
||||||
get_all_lf_type_landfalls <- function() {
|
get_all_lf_type_landfalls <- function() {
|
||||||
query <- view.all_lf_type_landfalls
|
query <- view.lf_id_location
|
||||||
|
|
||||||
result <- query %>% collect()
|
result <- query %>% collect()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user