mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
modify file formatting
This commit is contained in:
@@ -546,4 +546,3 @@ get_county_and_state <- function(df) {
|
|||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+62
-65
@@ -135,6 +135,13 @@ server <- function(input, output, session) {
|
|||||||
choices = unique_lfs$full_lf_id,
|
choices = unique_lfs$full_lf_id,
|
||||||
selected = unique_lfs$full_lf_id[1]
|
selected = unique_lfs$full_lf_id[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
updateSliderInput(
|
||||||
|
session,
|
||||||
|
"growth_trend_map_slider",
|
||||||
|
min = storm_selection$storm_year,
|
||||||
|
value = storm_selection$storm_year
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
observeEvent(input$load_storm, {
|
observeEvent(input$load_storm, {
|
||||||
@@ -304,12 +311,7 @@ server <- function(input, output, session) {
|
|||||||
arrange(datetime)
|
arrange(datetime)
|
||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
}) %>%
|
})
|
||||||
bindCache(
|
|
||||||
storm_selection$storm_year,
|
|
||||||
storm_selection$storm_name,
|
|
||||||
storm_selection$storm_basin
|
|
||||||
)
|
|
||||||
|
|
||||||
output$track_map <- renderLeaflet({
|
output$track_map <- renderLeaflet({
|
||||||
track_data <- storm_track()
|
track_data <- storm_track()
|
||||||
@@ -534,26 +536,26 @@ server <- function(input, output, session) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
g <- dygraph(track_xts) %>%
|
g <- dygraph(track_xts) %>%
|
||||||
dyAxis("y", label = "Windspeed (kt)") %>%
|
dyAxis("y", label = "Windspeed (kt)") %>%
|
||||||
dyAxis("y2", label = "Pressure (mb)", independentTicks = TRUE) %>%
|
dyAxis("y2", label = "Pressure (mb)", independentTicks = TRUE) %>%
|
||||||
dySeries("Windspeed", axis = "y", color = "#4dabf7") %>%
|
dySeries("Windspeed", axis = "y", color = "#4dabf7") %>%
|
||||||
dySeries("Pressure", axis = "y2", color = "#f03e3e") %>%
|
dySeries("Pressure", axis = "y2", color = "#f03e3e") %>%
|
||||||
dyOptions(drawGrid = FALSE) %>%
|
dyOptions(drawGrid = FALSE) %>%
|
||||||
dyLegend(show = "always")
|
dyLegend(show = "always")
|
||||||
|
|
||||||
Reduce(function(g, i) {
|
Reduce(
|
||||||
g %>% dyShading(
|
function(g, i) {
|
||||||
from = track_data$datetime[i],
|
g %>%
|
||||||
to = track_data$datetime[i + 1],
|
dyShading(
|
||||||
color = paste0(track_data$line_color[i], "33")
|
from = track_data$datetime[i],
|
||||||
)
|
to = track_data$datetime[i + 1],
|
||||||
}, seq_len(nrow(track_data) - 1), init = g)
|
color = paste0(track_data$line_color[i], "33")
|
||||||
}) %>%
|
)
|
||||||
bindCache(
|
},
|
||||||
storm_selection$storm_year,
|
seq_len(nrow(track_data) - 1),
|
||||||
storm_selection$storm_name,
|
init = g
|
||||||
storm_selection$storm_basin
|
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
storm_yearly_normalization <- reactive({
|
storm_yearly_normalization <- reactive({
|
||||||
req(
|
req(
|
||||||
@@ -565,12 +567,7 @@ server <- function(input, output, session) {
|
|||||||
result <- get_all_normalized_cost_index(storm_selection)
|
result <- get_all_normalized_cost_index(storm_selection)
|
||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
}) %>%
|
})
|
||||||
bindCache(
|
|
||||||
storm_selection$storm_year,
|
|
||||||
storm_selection$storm_name,
|
|
||||||
storm_selection$storm_basin
|
|
||||||
)
|
|
||||||
|
|
||||||
output$cost_index_chart <- renderDygraph({
|
output$cost_index_chart <- renderDygraph({
|
||||||
req(
|
req(
|
||||||
@@ -648,30 +645,6 @@ server <- function(input, output, session) {
|
|||||||
dyAxis("x", drawGrid = F) %>%
|
dyAxis("x", drawGrid = F) %>%
|
||||||
dyLegend(show = "always", width = 400, hideOnMouseOut = FALSE) %>%
|
dyLegend(show = "always", width = 400, hideOnMouseOut = FALSE) %>%
|
||||||
dyRangeSelector()
|
dyRangeSelector()
|
||||||
}) %>%
|
|
||||||
bindCache(
|
|
||||||
storm_selection$storm_year,
|
|
||||||
storm_selection$storm_name,
|
|
||||||
storm_selection$storm_basin,
|
|
||||||
input$storm_overview_cost_index_lf_select,
|
|
||||||
input$storm_overview_cost_index_mmh_mmp,
|
|
||||||
input$storm_overview_cost_index_scale,
|
|
||||||
input$storm_overview_cost_index_y_scale
|
|
||||||
)
|
|
||||||
|
|
||||||
observe({
|
|
||||||
req(
|
|
||||||
storm_selection$storm_basin,
|
|
||||||
storm_selection$storm_year,
|
|
||||||
storm_selection$storm_name
|
|
||||||
)
|
|
||||||
|
|
||||||
updateSliderInput(
|
|
||||||
session,
|
|
||||||
"growth_trend_map_slider",
|
|
||||||
min = storm_selection$storm_year,
|
|
||||||
value = storm_selection$storm_year
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
growth_counties <- reactive({
|
growth_counties <- reactive({
|
||||||
@@ -703,33 +676,57 @@ server <- function(input, output, session) {
|
|||||||
st_as_sf(wkt = "geom_wkt")
|
st_as_sf(wkt = "geom_wkt")
|
||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
}) %>%
|
|
||||||
bindCache(
|
|
||||||
storm_selection$storm_year,
|
|
||||||
storm_selection$storm_name,
|
|
||||||
storm_selection$storm_basin,
|
|
||||||
input$growth_trend_lf_select
|
|
||||||
)
|
|
||||||
|
|
||||||
output$growth_map <- renderLeaflet({
|
|
||||||
leaflet() %>%
|
|
||||||
addProviderTiles("Stadia.AlidadeSmooth")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
observe({
|
output$growth_map <- renderLeaflet({
|
||||||
req(growth_counties())
|
req(
|
||||||
|
growth_counties(),
|
||||||
|
input$growth_trend_map_slider,
|
||||||
|
input$growth_map_metric
|
||||||
|
)
|
||||||
|
|
||||||
counties_data <- growth_counties()
|
counties_data <- growth_counties()
|
||||||
combined_geom <- st_union(counties_data)
|
combined_geom <- st_union(counties_data)
|
||||||
growth_bbox <- st_bbox(combined_geom)
|
growth_bbox <- st_bbox(combined_geom)
|
||||||
|
|
||||||
leafletProxy("growth_map") %>%
|
growth_year <- input$growth_trend_map_slider
|
||||||
|
growth_county_year <- counties_data %>%
|
||||||
|
filter(year == growth_year)
|
||||||
|
|
||||||
|
map <- leaflet() %>%
|
||||||
|
addProviderTiles("Stadia.AlidadeSmooth") %>%
|
||||||
fitBounds(
|
fitBounds(
|
||||||
lng1 = growth_bbox[["xmin"]],
|
lng1 = growth_bbox[["xmin"]],
|
||||||
lng2 = growth_bbox[["xmax"]],
|
lng2 = growth_bbox[["xmax"]],
|
||||||
lat1 = growth_bbox[["ymin"]],
|
lat1 = growth_bbox[["ymin"]],
|
||||||
lat2 = growth_bbox[["ymax"]]
|
lat2 = growth_bbox[["ymax"]]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (input$growth_map_metric == "Population") {
|
||||||
|
map <- map %>%
|
||||||
|
addPolygons(
|
||||||
|
data = growth_county_year,
|
||||||
|
group = "counties",
|
||||||
|
fillColor = "red",
|
||||||
|
color = "red",
|
||||||
|
fillOpacity = ~population_opacity,
|
||||||
|
weight = 1,
|
||||||
|
popup = ~name
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
map <- map %>%
|
||||||
|
addPolygons(
|
||||||
|
data = growth_county_year,
|
||||||
|
group = "counties",
|
||||||
|
fillColor = "blue",
|
||||||
|
color = "blue",
|
||||||
|
fillOpacity = ~housing_opacity,
|
||||||
|
weight = 1,
|
||||||
|
popup = ~name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return(map)
|
||||||
})
|
})
|
||||||
|
|
||||||
observe({
|
observe({
|
||||||
|
|||||||
Reference in New Issue
Block a user