clarified comments
This commit is contained in:
parent
4b75d15a6e
commit
d4aca67ed2
@ -2,7 +2,7 @@
|
|||||||
library(nhdplusTools)
|
library(nhdplusTools)
|
||||||
library(sf)
|
library(sf)
|
||||||
|
|
||||||
# set data dir
|
# set hydrologic data dir
|
||||||
data_dir <- "data"
|
data_dir <- "data"
|
||||||
ifelse(
|
ifelse(
|
||||||
!dir.exists(file.path(getwd(), paste0(data_dir, "/hydrologic"))),
|
!dir.exists(file.path(getwd(), paste0(data_dir, "/hydrologic"))),
|
||||||
@ -15,6 +15,7 @@ nhdplusTools_data_dir(dir = paste0(data_dir, "/hydrologic"))
|
|||||||
extent <- read.csv(file = "extent.csv")
|
extent <- read.csv(file = "extent.csv")
|
||||||
crs <- 4269
|
crs <- 4269
|
||||||
|
|
||||||
|
# make extent a polygon
|
||||||
extent_poly <- st_polygon(
|
extent_poly <- st_polygon(
|
||||||
x = list(
|
x = list(
|
||||||
cbind(
|
cbind(
|
||||||
@ -24,7 +25,10 @@ extent_poly <- st_polygon(
|
|||||||
)
|
)
|
||||||
|
|
||||||
extent_poly <- st_sfc(extent_poly, crs=4326)
|
extent_poly <- st_sfc(extent_poly, crs=4326)
|
||||||
|
# make extent a bounding box
|
||||||
extent_bbox <- st_bbox(st_transform(x = extent_poly, crs))
|
extent_bbox <- st_bbox(st_transform(x = extent_poly, crs))
|
||||||
|
|
||||||
|
# make list of extent coordinates
|
||||||
extent <- list(longitude_max = max(extent$longitude),
|
extent <- list(longitude_max = max(extent$longitude),
|
||||||
longitude_min = min(extent$longitude),
|
longitude_min = min(extent$longitude),
|
||||||
latitude_max = max(extent$latitude),
|
latitude_max = max(extent$latitude),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# load libraries
|
# load libraries
|
||||||
library(nhdplusTools)
|
library(nhdplusTools)
|
||||||
library(sf)
|
|
||||||
|
|
||||||
# get watershed areas
|
# get watershed areas
|
||||||
extent_huc <- get_huc(AOI = extent_poly, buffer = 0, type = "huc04")
|
extent_huc <- get_huc(AOI = extent_poly, buffer = 0, type = "huc04")
|
||||||
@ -12,11 +11,13 @@ download_nhdplushr(nhdplusTools_data_dir(), extent_huc$huc4, download_files = TR
|
|||||||
get_vaa()
|
get_vaa()
|
||||||
|
|
||||||
# combine data into geopackage
|
# combine data into geopackage
|
||||||
|
# identify which layers to use
|
||||||
layers <- c("NHDArea",
|
layers <- c("NHDArea",
|
||||||
"NHDFlowline",
|
"NHDFlowline",
|
||||||
"NHDWaterbody",
|
"NHDWaterbody",
|
||||||
"NHDPlusLandSea")
|
"NHDPlusLandSea")
|
||||||
|
|
||||||
|
# save data into "data.gpkg" file
|
||||||
data <- get_nhdplushr(hr_dir = nhdplusTools_data_dir(),
|
data <- get_nhdplushr(hr_dir = nhdplusTools_data_dir(),
|
||||||
out_gpkg = paste0(nhdplusTools_data_dir(),"/data.gpkg"),
|
out_gpkg = paste0(nhdplusTools_data_dir(),"/data.gpkg"),
|
||||||
layers = layers,
|
layers = layers,
|
||||||
|
@ -17,7 +17,7 @@ units <- "in"
|
|||||||
res <- 600
|
res <- 600
|
||||||
margin <- 0
|
margin <- 0
|
||||||
|
|
||||||
# set state to highlight
|
# set state to highlight from political map
|
||||||
state <- c("Wisconsin")
|
state <- c("Wisconsin")
|
||||||
|
|
||||||
# plot map
|
# plot map
|
||||||
@ -53,7 +53,8 @@ plot_map <- function () {
|
|||||||
add = TRUE)
|
add = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
# save figure
|
## save figures
|
||||||
|
## generate tiff
|
||||||
# tiff(filename = paste0(figure_dir,"/map.tiff"),
|
# tiff(filename = paste0(figure_dir,"/map.tiff"),
|
||||||
# width = width,
|
# width = width,
|
||||||
# height = height,
|
# height = height,
|
||||||
@ -65,6 +66,7 @@ plot_map <- function () {
|
|||||||
# plot_map()
|
# plot_map()
|
||||||
# dev.off()
|
# dev.off()
|
||||||
#
|
#
|
||||||
|
## generate jpeg
|
||||||
# jpeg(filename = paste0(figure_dir,"/map.jpg"),
|
# jpeg(filename = paste0(figure_dir,"/map.jpg"),
|
||||||
# width = width,
|
# width = width,
|
||||||
# height = height,
|
# height = height,
|
||||||
@ -76,6 +78,7 @@ plot_map <- function () {
|
|||||||
# plot_map()
|
# plot_map()
|
||||||
# dev.off()
|
# dev.off()
|
||||||
|
|
||||||
|
# generate png
|
||||||
png(filename = paste0(figure_dir, "/map.png"),
|
png(filename = paste0(figure_dir, "/map.png"),
|
||||||
width = width,
|
width = width,
|
||||||
height = height,
|
height = height,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user