Skip to main content

US EHE/ECE GridEX Data Loading

gridex
tutorial
How to load GridEx data?
Author

Pedram Fard

Published

January 15, 2024

Quick tutorial on loading the EHE/ECE GridEX data

Note

This tutorial loads the state-level event summary from the January 2024 GridEX release, pinned to a fixed commit of the GridEX repository. That summary file was later retired upstream; see the repository for the current data files.

Loading the base spatial data set including Counties and States boundaries

states_file_path <- url('https://github.com/epedram/us_ehe_ece/raw/bbfef02e3c958b74b61cc60333f7a5d794da3c56/iv_ehe_ece_data_integration/data/us49_states_geo_tigris.rds')

states_geo <- readRDS(states_file_path)[[1]]
Warning in readRDS(states_file_path): strings not representable in native
encoding will be translated to UTF-8
counties_file_path <- url('https://github.com/epedram/us_ehe_ece/raw/bbfef02e3c958b74b61cc60333f7a5d794da3c56/iv_ehe_ece_data_integration/data/us49_counties_geo_tigris.rds')

counties_geo <- readRDS(counties_file_path)[[1]]
Warning in readRDS(counties_file_path): strings not representable in native
encoding will be translated to UTF-8
plot(counties_geo[1])

Loading the aggregate extreme events data set

events_catalog_file_path <- url('https://github.com/epedram/us_ehe_ece/raw/bbfef02e3c958b74b61cc60333f7a5d794da3c56/iv_ehe_ece_data_integration/data/States_events_by_type_sf_2008_2022.rds')

events_catalog_sf <- readRDS(events_catalog_file_path)[[1]] %>% 
  dplyr::filter(event_type == "Extreme Heat Event")
Warning in readRDS(events_catalog_file_path): strings not representable in
native encoding will be translated to UTF-8
glimpse(events_catalog_sf)
Rows: 49
Columns: 10
$ GEOID                         <chr> "01", "04", "05", "06", "08", "09", "10"~
$ STATE_NAME                    <chr> "Alabama", "Arizona", "Arkansas", "Calif~
$ NAME                          <chr> "Alabama", "Arizona", "Arkansas", "Calif~
$ event_type                    <chr> "Extreme Heat Event", "Extreme Heat Even~
$ total_event_days              <int> 357, 226, 281, 493, 291, 89, 108, 93, 53~
$ max_impacted_area_hectare     <dbl> 14492793.2, 37304642.6, 19239879.7, 4423~
$ average_impacted_area_hectare <dbl> 1314253.1, 7129026.6, 2458499.7, 3493038~
$ sd_impacted_area_hectare      <dbl> 2123813.5, 9191985.2, 3579130.2, 5823025~
$ model_params                  <fct> US_ehe_ece_65_counties_6_2_ehcmi__minmax~
$ geometry                      <MULTIPOLYGON [m]> MULTIPOLYGON (((-9802057 35~

Example of merging States boundaries with summarized EHE data

state_boundaris_ehe_catalog <- merge(states_geo,
          events_catalog_sf %>% st_drop_geometry(),
          by.x="GEOID",
          by.y="GEOID",
          all.x = TRUE,
          all.y = TRUE,
          suffix = c("","_sp")) %>% st_as_sf() 

glimpse(state_boundaris_ehe_catalog)
Rows: 49
Columns: 20
$ GEOID                         <chr> "01", "04", "05", "06", "08", "09", "10"~
$ STATEFP                       <chr> "01", "04", "05", "06", "08", "09", "10"~
$ STATENS                       <chr> "01779775", "01779777", "00068085", "017~
$ AFFGEOID                      <chr> "0400000US01", "0400000US04", "0400000US~
$ STUSPS                        <chr> "AL", "AZ", "AR", "CA", "CO", "CT", "DE"~
$ NAME                          <chr> "Alabama", "Arizona", "Arkansas", "Calif~
$ LSAD                          <chr> "00", "00", "00", "00", "00", "00", "00"~
$ ALAND                         <dbl> 131185042550, 294365853885, 134660743067~
$ AWATER                        <dbl> 4582333181, 853990728, 3121974727, 20291~
$ STATE_NAME                    <chr> "Alabama", "Arizona", "Arkansas", "Calif~
$ Climate_Region                <chr> "Southeast", "Southwest", "South", "West~
$ STATE_NAME_sp                 <chr> "Alabama", "Arizona", "Arkansas", "Calif~
$ NAME_sp                       <chr> "Alabama", "Arizona", "Arkansas", "Calif~
$ event_type                    <chr> "Extreme Heat Event", "Extreme Heat Even~
$ total_event_days              <int> 357, 226, 281, 493, 291, 89, 108, 93, 53~
$ max_impacted_area_hectare     <dbl> 14492793.2, 37304642.6, 19239879.7, 4423~
$ average_impacted_area_hectare <dbl> 1314253.1, 7129026.6, 2458499.7, 3493038~
$ sd_impacted_area_hectare      <dbl> 2123813.5, 9191985.2, 3579130.2, 5823025~
$ model_params                  <fct> US_ehe_ece_65_counties_6_2_ehcmi__minmax~
$ geometry                      <MULTIPOLYGON [m]> MULTIPOLYGON (((-9848795 37~

Mapping the summarized EHE data merged with the States boundaries

total_ehe_plot <- ggplot() +
    geom_sf(data = state_boundaris_ehe_catalog,
            aes(fill = total_event_days),
            lwd = .1) + 
    scale_fill_viridis(option="inferno", 
                       direction = -1,
                       na.value = NA) +

    labs(fill = "Total Number of EHE Days (2008-2022)") +

    theme_void() + 
    theme(legend.position = "bottom")

#ggsave("./data/Total_Number_of_EHE_Days_2008_2022.jpg",
#         plot = total_ehe_plot, dpi = 300,
#         width = 22, height = 18, units = "cm")

total_ehe_plot

For more information: