made it easier to save in multiple formats
This commit is contained in:
parent
82fc901902
commit
f6f22d5d97
@ -9,6 +9,37 @@ ifelse(!dir.exists(file.path(getwd(), figure_dir)), dir.create(file.path(getwd()
|
|||||||
colors <- list(darkblue = "#062e57",
|
colors <- list(darkblue = "#062e57",
|
||||||
lightblue = "#b1dcf3")
|
lightblue = "#b1dcf3")
|
||||||
|
|
||||||
|
# plot map
|
||||||
|
plot_map <- function () {
|
||||||
|
plot(sf::st_geometry(extent_poly),
|
||||||
|
col = colors$darkblue,
|
||||||
|
extent = extent_bbox,
|
||||||
|
xlim = c(extent$longitude_min, extent$longitude_max),
|
||||||
|
ylim = c(extent$latitude_min, extent$latitude_max),
|
||||||
|
border = "black")
|
||||||
|
plot(sf::st_geometry(data$NHDWaterbody),
|
||||||
|
col = colors$lightblue,
|
||||||
|
border = NA,
|
||||||
|
extent = extent_bbox,
|
||||||
|
xlim = c(extent$longitude_min, extent$longitude_max),
|
||||||
|
ylim = c(extent$latitude_min, extent$latitude_max),
|
||||||
|
add = TRUE)
|
||||||
|
plot(sf::st_geometry(data$NHDArea),
|
||||||
|
col = colors$lightblue,
|
||||||
|
border = NA,
|
||||||
|
extent = extent_bbox,
|
||||||
|
xlim = c(extent$longitude_min, extent$longitude_max),
|
||||||
|
ylim = c(extent$latitude_min, extent$latitude_max),
|
||||||
|
add = TRUE)
|
||||||
|
plot(sf::st_geometry(data$NHDFlowline),
|
||||||
|
col = colors$lightblue,
|
||||||
|
lwd = data$NHDFlowline$TotDASqKM^0.3204*0.0446,
|
||||||
|
border = NA,
|
||||||
|
extent = extent_bbox,
|
||||||
|
xlim = c(extent$longitude_min, extent$longitude_max),
|
||||||
|
ylim = c(extent$latitude_min, extent$latitude_max),
|
||||||
|
add = TRUE)
|
||||||
|
}
|
||||||
|
|
||||||
# save figure
|
# save figure
|
||||||
tiff(filename = paste0(figure_dir,"/map.tiff"),
|
tiff(filename = paste0(figure_dir,"/map.tiff"),
|
||||||
@ -17,43 +48,13 @@ tiff(filename = paste0(figure_dir,"/map.tiff"),
|
|||||||
units = "in",
|
units = "in",
|
||||||
res = 600,
|
res = 600,
|
||||||
compression = "lzw")
|
compression = "lzw")
|
||||||
|
plot_map()
|
||||||
|
dev.off()
|
||||||
|
|
||||||
png(filename = paste0(figure_dir, "/map.png"),
|
png(filename = paste0(figure_dir, "/map.png"),
|
||||||
width = 11,
|
width = 11,
|
||||||
height = 17,
|
height = 17,
|
||||||
units = "in",
|
units = "in",
|
||||||
res = 600)
|
res = 600)
|
||||||
|
plot_map()
|
||||||
# plot map
|
|
||||||
|
|
||||||
plot(sf::st_geometry(extent_poly),
|
|
||||||
col = colors$darkblue,
|
|
||||||
extent = extent_bbox,
|
|
||||||
xlim = c(extent$longitude_min, extent$longitude_max),
|
|
||||||
ylim = c(extent$latitude_min, extent$latitude_max),
|
|
||||||
border = "black")
|
|
||||||
plot(sf::st_geometry(data$NHDWaterbody),
|
|
||||||
col = colors$lightblue,
|
|
||||||
border = NA,
|
|
||||||
extent = extent_bbox,
|
|
||||||
xlim = c(extent$longitude_min, extent$longitude_max),
|
|
||||||
ylim = c(extent$latitude_min, extent$latitude_max),
|
|
||||||
add = TRUE)
|
|
||||||
plot(sf::st_geometry(data$NHDArea),
|
|
||||||
col = colors$lightblue,
|
|
||||||
border = NA,
|
|
||||||
extent = extent_bbox,
|
|
||||||
xlim = c(extent$longitude_min, extent$longitude_max),
|
|
||||||
ylim = c(extent$latitude_min, extent$latitude_max),
|
|
||||||
add = TRUE)
|
|
||||||
plot(sf::st_geometry(data$NHDFlowline),
|
|
||||||
col = colors$lightblue,
|
|
||||||
lwd = data$NHDFlowline$TotDASqKM^0.3204*0.0446,
|
|
||||||
border = NA,
|
|
||||||
extent = extent_bbox,
|
|
||||||
xlim = c(extent$longitude_min, extent$longitude_max),
|
|
||||||
ylim = c(extent$latitude_min, extent$latitude_max),
|
|
||||||
add = TRUE)
|
|
||||||
# finish saving figure
|
|
||||||
dev.off()
|
|
||||||
dev.off()
|
dev.off()
|
Loading…
x
Reference in New Issue
Block a user