made data and figure directories easier to change
This commit is contained in:
parent
ced316e78f
commit
82fc901902
@ -3,7 +3,13 @@ library(nhdplusTools)
|
|||||||
library(sf)
|
library(sf)
|
||||||
|
|
||||||
# set data dir
|
# set data dir
|
||||||
nhdplusTools_data_dir(dir = "data/hydrologic")
|
data_dir <- "data"
|
||||||
|
ifelse(
|
||||||
|
!dir.exists(file.path(getwd(), paste0(data_dir, "/hydrologic"))),
|
||||||
|
dir.create(file.path(getwd(), paste0(data_dir, "/hydrologic"), recursive = TRUE)),
|
||||||
|
FALSE)
|
||||||
|
|
||||||
|
nhdplusTools_data_dir(dir = paste0(data_dir, "/hydrologic"))
|
||||||
|
|
||||||
# load extent of map
|
# load extent of map
|
||||||
extent <- read.csv(file = "extent.csv")
|
extent <- read.csv(file = "extent.csv")
|
||||||
|
@ -10,7 +10,7 @@ for (layer in layers){
|
|||||||
|
|
||||||
# load political boundaries
|
# load political boundaries
|
||||||
political <- list(NULL)
|
political <- list(NULL)
|
||||||
political_boundaries <- list.files(path = "data/political_boundaries")
|
political_boundaries <- list.files(path = paste0(data_dir, "/political_boundaries"))
|
||||||
for (boundary in political_boundaries) {
|
for (boundary in political_boundaries) {
|
||||||
political[[boundary]] <- st_read(paste0("data/political_boundaries/", boundary))
|
political[[boundary]] <- st_read(paste0(data_dir, "/political_boundaries/", boundary))
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
# load libraries
|
# load libraries
|
||||||
library(sf)
|
library(sf)
|
||||||
|
|
||||||
|
# set dir to save figures to
|
||||||
|
figure_dir <- "figures"
|
||||||
|
ifelse(!dir.exists(file.path(getwd(), figure_dir)), dir.create(file.path(getwd(), figure_dir)), FALSE)
|
||||||
|
|
||||||
|
# set colors
|
||||||
colors <- list(darkblue = "#062e57",
|
colors <- list(darkblue = "#062e57",
|
||||||
lightblue = "#b1dcf3")
|
lightblue = "#b1dcf3")
|
||||||
|
|
||||||
|
|
||||||
# save figure
|
# save figure
|
||||||
tiff(filename = "figures/map.tiff",
|
tiff(filename = paste0(figure_dir,"/map.tiff"),
|
||||||
width = 11,
|
width = 11,
|
||||||
height = 17,
|
height = 17,
|
||||||
units = "in",
|
units = "in",
|
||||||
res = 600,
|
res = 600,
|
||||||
compression = "lzw")
|
compression = "lzw")
|
||||||
|
|
||||||
png(filename = "figures/map.png",
|
png(filename = paste0(figure_dir, "/map.png"),
|
||||||
width = 11,
|
width = 11,
|
||||||
height = 17,
|
height = 17,
|
||||||
units = "in",
|
units = "in",
|
||||||
@ -51,3 +56,4 @@ plot(sf::st_geometry(data$NHDFlowline),
|
|||||||
add = TRUE)
|
add = TRUE)
|
||||||
# finish saving figure
|
# finish saving figure
|
||||||
dev.off()
|
dev.off()
|
||||||
|
dev.off()
|
Loading…
x
Reference in New Issue
Block a user