mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
add fatality map test and heatmap
This commit is contained in:
@@ -546,3 +546,50 @@ get_county_and_state <- function(df) {
|
||||
|
||||
return(result)
|
||||
}
|
||||
|
||||
get_fatality_heatmap_data <- function(storm) {
|
||||
query <- tbl(con, I("fatal.conus_direct_fatalities")) %>%
|
||||
filter(
|
||||
storm_basin == storm$storm_basin,
|
||||
storm_year == storm$storm_year,
|
||||
storm_name == storm$storm_name
|
||||
) %>%
|
||||
select(state_fips, fatality_type, n = fatality_count)
|
||||
|
||||
result <- query %>%
|
||||
collect() %>%
|
||||
left_join(
|
||||
tbl(con, I("fips.states")) %>%
|
||||
select(state_fips, state_abbreviation) %>%
|
||||
collect(),
|
||||
by = "state_fips"
|
||||
) %>%
|
||||
mutate(
|
||||
state_label = if_else(state_fips == "00", "Unknown", state_abbreviation)
|
||||
)
|
||||
|
||||
return(result)
|
||||
}
|
||||
|
||||
get_fatality_map <- function(storm) {
|
||||
query <- tbl(con, I("fatal.conus_direct_fatalities")) %>%
|
||||
filter(
|
||||
storm_basin == storm$storm_basin,
|
||||
storm_year == storm$storm_year,
|
||||
storm_name == storm$storm_name
|
||||
) %>%
|
||||
inner_join(
|
||||
tbl(con, I("gis.us_states_boundary")) %>%
|
||||
rename(state_fips = statefp),
|
||||
by = "state_fips"
|
||||
) %>%
|
||||
mutate(
|
||||
geom_wkt = sql(
|
||||
"ST_AsText(ST_SimplifyPreserveTopology(ST_Transform(wkb_geometry, 4326), .001))"
|
||||
)
|
||||
)
|
||||
|
||||
result <- query %>% collect()
|
||||
|
||||
return(result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user