Skip to contents
TXLA_fips <- c("22", "48")
TXLA_tracts <- TXLA_fips |>
  map(~ tracts(state = .x, cb = TRUE)) |>
  bind_rows()

Getting raw data

harvey_hurdat2  <- get_hurdat2(
  storm_id = "HARVEY-2017",
  path = "raw-data/hurdat2"
)
harvey_start <- min(harvey_hurdat2$datetime)
harvey_end <- max(harvey_hurdat2$datetime)

harvey_nClimGrid <- get_nClimGrid(
  interval = interval(harvey_start, harvey_end + days(2)),
  path = "raw-data/nClimGrid"
)

harvey_eaglei <- get_eaglei(
  interval = interval(harvey_start, harvey_end + days(5)),
  path = "raw-data/eaglei"
)

harvey_stormevents <- get_stormevents(
  interval = interval(harvey_start, harvey_end),
  path = "raw-data/stormevents"
)

Calculating measures

harvey_closest_dist <- calc_closest_dist(harvey_hurdat2, TXLA_tracts)
harvey_outage <- calc_outage(harvey_eaglei, TXLA_fips)
harvey_daily_avgs <- calc_daily_avgs(harvey_nClimGrid, TXLA_tracts)
harvey_anderson_prcp <- calc_anderson_prcp(harvey_daily_avgs, harvey_closest_dist)
harvey_anderson_wind <- calc_anderson_wind(harvey_hurdat2, TXLA_tracts)
library(tmap)

harvey_anderson_prcp <- calc_anderson_prcp(harvey_daily_avgs, harvey_closest_dist, days_before = 4, days_after = 4)

harvey_anderson_prcp |>
  left_join(x = TXLA_tracts, c("GEOID" = "geoid")) |>
tm_shape() +
  tm_polygons("cum_prcp", lwd = 0)

harvey_closest_dist |>
  mutate(closest_date = as_date(closest_date)) |>
  left_join(x = TXLA_tracts, c("GEOID" = "geoid")) |>
tm_shape() +
  tm_polygons("closest_date", lwd = 0)


harvey_outage |>
  left_join(x = TXLA_tracts) |>
  ggplot() +
    geom_sf(aes(fill = max_pct_out))