Compare commits
No commits in common. "1508919f762cc921662f7f1f02610deb3e7d4b55" and "87e087a5a748f73f141a42e35f59cf78f9a16a83" have entirely different histories.
1508919f76
...
87e087a5a7
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,5 +4,3 @@
|
|||||||
.Ruserdata
|
.Ruserdata
|
||||||
|
|
||||||
data/*
|
data/*
|
||||||
|
|
||||||
figures/*
|
|
||||||
|
@ -30,6 +30,7 @@ extent <- list(longitude_max = max(extent$longitude),
|
|||||||
latitude_max = max(extent$latitude),
|
latitude_max = max(extent$latitude),
|
||||||
latitude_min = min(extent$latitude))
|
latitude_min = min(extent$latitude))
|
||||||
|
|
||||||
|
|
||||||
# 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")
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# load libraries
|
# load libraries
|
||||||
library(nhdplusTools)
|
|
||||||
library(sf)
|
library(sf)
|
||||||
|
|
||||||
# reload extent data so you don't need to run the download data script again
|
# reload extent data so you don't need to run the download data script again
|
||||||
@ -27,18 +26,13 @@ extent <- list(longitude_max = max(extent$longitude),
|
|||||||
# load and crop hydrologic data
|
# load and crop hydrologic data
|
||||||
data <- list(NULL)
|
data <- list(NULL)
|
||||||
sf_use_s2(FALSE)
|
sf_use_s2(FALSE)
|
||||||
layers <- c("NHDArea",
|
|
||||||
"NHDFlowline",
|
|
||||||
"NHDWaterbody",
|
|
||||||
"NHDPlusLandSea")
|
|
||||||
for (layer in layers){
|
for (layer in layers){
|
||||||
data[[layer]] <- st_crop(st_read(paste0(nhdplusTools_data_dir(),"/data.gpkg"), layer = layer), y = extent_bbox)
|
data[[layer]] <- st_crop(st_read(paste0(nhdplusTools_data_dir(),"/data.gpkg"), layer = layer), y = extent_bbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
# load political boundaries
|
# load political boundaries
|
||||||
political <- st_crop(
|
political <- list(NULL)
|
||||||
st_transform(
|
political_boundaries <- list.files(path = paste0(data_dir, "/political_boundaries"))
|
||||||
st_read(
|
for (boundary in political_boundaries) {
|
||||||
paste0(data_dir, "/political_boundaries/bound_p/boundaries_p_2021_v3.shp")),
|
political[[boundary]] <- st_read(paste0(data_dir, "/political_boundaries/", boundary))
|
||||||
crs=crs),
|
}
|
||||||
y = extent_bbox)
|
|
||||||
|
@ -7,74 +7,47 @@ ifelse(!dir.exists(file.path(getwd(), figure_dir)), dir.create(file.path(getwd()
|
|||||||
|
|
||||||
# set colors
|
# set colors
|
||||||
colors <- list(darkblue = "#062e57",
|
colors <- list(darkblue = "#062e57",
|
||||||
lightblue = "#b1dcf3",
|
lightblue = "#b1dcf3")
|
||||||
lightgrey = "#6D6D6D")
|
|
||||||
|
|
||||||
# set dimensions of figures
|
# set dimensions of figures
|
||||||
width <- 8
|
width <- 8.5
|
||||||
height <- 10
|
height <- 11
|
||||||
units <- "in"
|
units <- "in"
|
||||||
res <- 600
|
res <- 600
|
||||||
margin <- 0
|
margin <- 0
|
||||||
|
|
||||||
# set state to highlight
|
|
||||||
state <- c("Wisconsin")
|
|
||||||
|
|
||||||
# plot map
|
# plot map
|
||||||
plot_map <- function () {
|
plot_map <- function () {
|
||||||
plot(sf::st_geometry(extent_poly),
|
plot(sf::st_geometry(extent_poly),
|
||||||
col = colors$lightblue,
|
|
||||||
border = NA)
|
|
||||||
plot(sf::st_geometry(political$geometry),
|
|
||||||
col = colors$lightgrey,
|
|
||||||
border = NA,
|
|
||||||
add = TRUE)
|
|
||||||
plot(sf::st_geometry(political[political$NAME_En %in% state, ]),
|
|
||||||
col = colors$darkblue,
|
col = colors$darkblue,
|
||||||
border = NA,
|
border = "black")
|
||||||
add = TRUE)
|
plot(sf::st_geometry(data$NHDWaterbody),
|
||||||
plot(sf::st_geometry(data$NHDWaterbody),
|
|
||||||
col = colors$lightblue,
|
col = colors$lightblue,
|
||||||
border = NA,
|
border = NA,
|
||||||
add = TRUE)
|
add = TRUE)
|
||||||
plot(sf::st_geometry(data$NHDArea),
|
plot(sf::st_geometry(data$NHDArea),
|
||||||
col = colors$lightblue,
|
col = colors$lightblue,
|
||||||
border = NA,
|
border = NA,
|
||||||
add = TRUE)
|
add = TRUE)
|
||||||
plot(sf::st_geometry(data$NHDFlowline),
|
plot(sf::st_geometry(data$NHDFlowline),
|
||||||
col = colors$lightblue,
|
col = colors$lightblue,
|
||||||
lwd = data$NHDFlowline$TotDASqKM^0.3204*0.0446,
|
lwd = data$NHDFlowline$TotDASqKM^0.3204*0.0446,
|
||||||
border = NA,
|
border = NA,
|
||||||
add = TRUE)
|
add = TRUE)
|
||||||
plot(sf::st_geometry(extent_poly),
|
|
||||||
col = NA,
|
|
||||||
border = "black",
|
|
||||||
lwd = 1,
|
|
||||||
add = TRUE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# save figure
|
# save figure
|
||||||
# tiff(filename = paste0(figure_dir,"/map.tiff"),
|
tiff(filename = paste0(figure_dir,"/map.tiff"),
|
||||||
# width = width,
|
width = width,
|
||||||
# height = height,
|
height = height,
|
||||||
# units = units,
|
units = units,
|
||||||
# res = res,
|
res = res,
|
||||||
# compression = "lzw")
|
compression = "lzw")
|
||||||
# par(mai=c(margin, margin, margin, margin))
|
par(mai=c(margin, margin, margin, margin))
|
||||||
# par(mar=c(1,1,1,1))
|
par(mar=c(1,1,1,1))
|
||||||
# plot_map()
|
plot_map()
|
||||||
# dev.off()
|
dev.off()
|
||||||
#
|
|
||||||
# jpeg(filename = paste0(figure_dir,"/map.jpg"),
|
|
||||||
# width = width,
|
|
||||||
# height = height,
|
|
||||||
# units = units,
|
|
||||||
# res = res,
|
|
||||||
# quality = 93)
|
|
||||||
# par(mai=c(margin, margin, margin, margin))
|
|
||||||
# par(mar=c(1,1,1,1))
|
|
||||||
# plot_map()
|
|
||||||
# dev.off()
|
|
||||||
|
|
||||||
png(filename = paste0(figure_dir, "/map.png"),
|
png(filename = paste0(figure_dir, "/map.png"),
|
||||||
width = width,
|
width = width,
|
||||||
|
@ -6,10 +6,10 @@ Downloads USGS data for a given location and makes a pretty map of the rivers. T
|
|||||||
1. Clone the repository
|
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).
|
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:
|
3. Run the scripts:
|
||||||
- `01_download_data.R` - This will take the longest. The whole of Wisconsin downloads ~12GB of data. It downloads the data to a `data` directory in the repo
|
- `01_download_data.R` - This will take the longest. The whole of Wisconsin downloads ~12GB of data
|
||||||
- `02_process_data.R` - This loads and processes the data. After the initial run downloading the data for a given extent, you can start with this script.
|
- `02_process_data.R`
|
||||||
- `03_make_figures.R` - This generates figures in a `figures` directory in the repo.
|
- `03_make_figures.R`
|
||||||
|
|
||||||
|
|
||||||
## Example figure
|
## Example figure
|
||||||

|

|
||||||
|
BIN
example.png
BIN
example.png
Binary file not shown.
Before Width: | Height: | Size: 15 MiB |
@ -1,3 +1,3 @@
|
|||||||
latitude,longitude
|
latitude,longitude
|
||||||
47.73208,-93.55154
|
47.33402,-93.10419
|
||||||
41.49273,-86.64896
|
42.43754,-86.832
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
latitude,longitude
|
|
||||||
48.50775,-124.91972
|
|
||||||
46.88398,-122.07015
|
|
|
@ -1,3 +0,0 @@
|
|||||||
latitude,longitude
|
|
||||||
49.17657,-125.43151
|
|
||||||
45.23644,-115.81455
|
|
|
@ -1,3 +0,0 @@
|
|||||||
latitude,longitude
|
|
||||||
47.73208,-93.55154
|
|
||||||
41.49273,-86.64896
|
|
|
Loading…
x
Reference in New Issue
Block a user