initial 01_download_data.R

This commit is contained in:
Ben Varick 2023-10-16 09:55:10 -05:00
parent af217a1751
commit b0a038504f
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,30 @@
# load libraries
library(tidyverse)
library(nhdplusTools)
library(sf)
# load extent of map
extent <- read.csv(file = "extent.csv")
crs <- 26916
extent_poly <- st_polygon(
x = list(
cbind(
extent$longitude[c(1,2,2,1,1)],
extent$latitude[c(1,1,2,2,1)])
)
)
extent_poly <- st_sfc(extent_poly, crs=4326)
extent <- list(longitude_max = max(extent$longitude),
longitude_min = min(extent$longitude),
latitude_max = max(extent$latitude),
latitude_min = min(extent$latitude))
# get watershed areas
extent_huc <- get_huc(AOI = extent_poly, buffer = 0, type = "huc04")
# download data
download_nhdplushr("data", extent_huc$huc4, download_files = TRUE)

3
extent.csv Normal file
View File

@ -0,0 +1,3 @@
latitude,longitude
43.63839,-89.97779
42.52677,-88.52104
1 latitude longitude
2 43.63839 -89.97779
3 42.52677 -88.52104