From 549d67236f292004a04eceb95c83394d03923c8d Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Mon, 16 Oct 2023 13:39:07 -0500 Subject: [PATCH] added political boundaries adjusted data dir added steps and example to readme --- 01_download_data.R | 2 +- 02_process_data.R | 9 ++++++++- 03_make_figures.R | 1 - README.md | 10 +++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/01_download_data.R b/01_download_data.R index 38ce473..2babbe6 100644 --- a/01_download_data.R +++ b/01_download_data.R @@ -3,7 +3,7 @@ library(nhdplusTools) library(sf) # set data dir -nhdplusTools_data_dir(dir = "data") +nhdplusTools_data_dir(dir = "data/hydrologic") # load extent of map extent <- read.csv(file = "extent.csv") diff --git a/02_process_data.R b/02_process_data.R index 9f8a990..2fb1cf9 100644 --- a/02_process_data.R +++ b/02_process_data.R @@ -1,9 +1,16 @@ # load libraries library(sf) -# load and crop data +# load and crop hydrologic data data <- list(NULL) sf_use_s2(FALSE) for (layer in layers){ data[[layer]] <- st_crop(st_read(paste0(nhdplusTools_data_dir(),"/data.gpkg"), layer = layer), y = extent_bbox) } + +# load political boundaries +political <- list(NULL) +political_boundaries <- list.files(path = "data/political_boundaries") +for (boundary in political_boundaries) { + political[[boundary]] <- st_read(paste0("data/political_boundaries/", boundary)) +} diff --git a/03_make_figures.R b/03_make_figures.R index 25813be..518b2e2 100644 --- a/03_make_figures.R +++ b/03_make_figures.R @@ -42,6 +42,5 @@ plot(sf::st_geometry(data$NHDFlowline), xlim = c(extent$longitude_min, extent$longitude_max), ylim = c(extent$latitude_min, extent$latitude_max), add = TRUE) - # finish saving figure dev.off() diff --git a/README.md b/README.md index 086cacd..c832e8f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # pretty_rivers -Downloads USGS data for a given location and makes a pretty map of the rivers. The width of the rivers is proportional to the area of land that the section of river drains. \ No newline at end of file +Downloads USGS data for a given location and makes a pretty map of the rivers. The width of the rivers is proportional to the area of land that the section of river drains. + +## To run : +1. Clone the repository +2. Edit the extent of the map you want to produce in `extent.csv`. Include lat/long coordinates of two opposite corners (i.e. top-left and bottom-right). +3. Run the scripts. Downloading the data and loading the data will take the longest. The whole of Wisconsin downloads ~12GB of data + +## Example figure +![example figure](figures/map.tiff)