WSIM-GLDAS Dataset Exploration and Visualizations
TO DO
- Write the actual code and narrative.
- Determine the region and time period of focus to draw in our use cases/human focused stories.
- Determine the method of exploration.
- Mimic our process?
- 12 month integration panels of the CON USA from 2000-2014 to identify areas of interest.
- Zoom in to locations of interest and switch to 1-month integration for the years identified in the previous step.
- Mimic our process?
Introduction
- Raster/vector visualization background?
- General
- Water resource specific
- Package background
- Basic plotting with stars/sf
- more advanced plotting with ggplot/ggmap
Setup
library(stars) # raster manipulation
library(sf) # vector manipulation
library(ggplot2) # advanced plotting
library(lubridate) # date/time manipulation
library(exactextractr) # zonal statisticsLoad Data
Load in data from previous vignette.
I think the previous vignette should end with a 2000-2014 12-month integration CONUS dataset.
Verify data structure with print or summary.
Exploratory Histogram
Create histogram of raster values for a single time step.
Basic plotting method is OK, but check if it can be done with ggplotso we can use a uniform palette across all modules.
Extreme values or other items of note might require additional visualization or other data exploration.
Multi-Panel Time Series
Create a multipanel time series of 12 month integration CONUSA; similar to what we used to identify our case studies. Each panel will represent 1 year.
Load in a CONUSA geojson from geoBoundaries. Copy methods from previous vignette.
Start with the basic plotting commands–create the time series with slice or other method used in previous vignette.
The palette will not exist and be difficult to use.
Try a built in palette for stars (not sure if possible?).
Introduce the official WSIM palette. This may only be helpful within a ggplot function.
# numbers are return period values for a composite surplus (blues) and deficit (reds) dataset
leg_colors<-c(
'#9B0039',
# -50 to -40
'#D44135',
# -40 to -20
'#FF8D43',
# -20 to -10
'#FFC754',
# -10 to -5
'#FFEDA3',
# -5 to -3
'#FFFFFF',
# -3 to 3
'#CEFFAD',
# 3 to 5
'#00F3B5',
# 5 to 10
'#00CFCE',
# 10 to 20
'#009ADE',
# 20 to 40
'#0045B5')Once hot spots are easily identified pick a region of interest to zoom in on using the 1 month integration dataset.
Load in the 1 month integration dataset and subset/index the dataset to the region of interest (copy code from previous vignette). Use dplyr::slice or other method to pull out just the 12 months from the year of interest. Code demonstrating these techniques in previous vignette.
Create a multi-panel figure with each panel representing 1 month to identify the most intense months of drought or flooding. Starting with this one maybe use ggplot and a nice palette, legend, and panel headings. Will probably have to use some sort of faceting to make individual panels (might not be possible).
Use Case Background
Now that we’ve keyed in on a particular event, bring in the backup information we’ve collected to discuss what actually happened.
Point Location Time Series
Visualize an individual cell with particular extreme or maybe volatile values. Use Google Maps to identify the latitude/longitude of a place of interest. Maybe an urban center or other important location in the region that suffered from the extreme event.
Create a vector with the point location.
Use stars::extract to extract raster values in the stack at the point location.
The resulting data frame of time series values should be inspected. It may also need to be converted from wide format to long format so it may be plotted in ggplot. Use either pivot wider/longer from dplyr or cast/melt from data.table.
Once in the proper format, plot using ggplot.
Population Exposure Plot
Use Gridded Population of the World and exactextractr to determine the number of people exposed to a given anomaly for each month of the year.
Background info on GPW would be appropriate. Same with exactextractr and zonal statistics.
Load in GPW data and the exactextractr package
Perform the time series zonal summary.
This might be a bit tricky; been a while for me. Have to look up the proper code. Dan has good examples on the exactextractr package website.
Resulting data.frame will probably need to be transformed to long (just like before), so it can be plotted.
Now plot the data in ggplot. I have some existing code I can pull to help with the plotting–or at least make it fancy.