update ui to include more features

This commit is contained in:
2025-07-15 00:12:12 -04:00
parent 3efbf9abf3
commit d754970536
2 changed files with 197 additions and 88 deletions
+44
View File
@@ -150,6 +150,50 @@ get_normalized_cost_index <- function(storm, full_lf_id) {
return(result)
}
test_query <- function() {
result <- dbGetQuery(con, "WITH yearly_totals AS (
SELECT
year,
SUM(population) as total_population,
SUM(housing_units) as total_housing_units
FROM metrics.pop_and_housing
WHERE state_fips = '12'
AND county_fips IN ('011', '021', '086', '087')
AND year BETWEEN 1926 AND 2024
GROUP BY year
),
base_year AS (
SELECT
total_population as base_population,
total_housing_units as base_housing
FROM yearly_totals
WHERE year = (SELECT MIN(year) FROM yearly_totals) -- Uses first year in dataset as base
)
SELECT
year,
total_population,
total_housing_units,
ROUND(total_population / base_population, 4) as population_index,
ROUND(total_housing_units / base_housing, 4) as housing_index
FROM yearly_totals
CROSS JOIN base_year
ORDER BY year;")
result <- result %>%
mutate(
year = as.Date(paste0(year, "-01-01"))
) %>%
select(
year, population_index, housing_index
)
result_ts <- result %>%
select(-year) %>%
xts(order.by = result$year)
return(result_ts)
}
# returns landfalls and data at landfall from HURDAT
get_hurdat_landfalls <- function(storm) {
query <- view.hurdat_track %>%