Skip to content
Snippets Groups Projects

Unequal access to water: how societal factors shape vulnerability to water insecurity

This repo uses R, Vue, and D3 to build an interactive data visualization website about indicators of vulnerability to water insecurity. In R there is a pipeline that uses the targets library to fetch, process, and visualize data. The rest of the files build the website.

This project:

  1. Pulls, processes, and visualizes data from the USGS Uncertainty Summary of Water Vulnerability in the Western US 2000-2022.

  2. Pull, processes, and visualizes data from the U.S. Census Bureau using the R package [tidycensus](https://walker-data.com/tidycensus/.

  3. Builds a javascript website using data visualization to communicate the motivation for the USGS Social and Economic Drivers project, highlighting how societal factors shape exposure to water-related hazards across the Western U.S.. The website can be accessed here

Running the targets pipeline in R

Clone the repo. In RStudio, run library(targets) and tar_make(). This will require tidycensus credentialing to run, see instructions below.

tidycensus set up

Adapted from package developers Kyle Walker & Matt Herman, to set up tidycensus run the following in the R Console:

# install.packages("tidycensus")
library(tidycensus)
library(tidyverse)

You will also need to set a Census API key. A key can be obtained from http://api.census.gov/data/key_signup.html.

census_api_key("YOUR API KEY GOES HERE", install = TRUE)
readRenviron("~/.Renviron")

Building the website locally

Clone the repo. In the directory, run npm install to install the required modules. Once the dependencies have been installed, run npm run dev to run locally from your browser.

To build the website locally you'll need npm v20 and node v8.1 or higher installed. To manage multiple versions of npm, you may try using nvm.