Skip to content

Commit

Permalink
add DEM to map plots
Browse files Browse the repository at this point in the history
  • Loading branch information
acrunyon committed Aug 16, 2021
1 parent 35d0706 commit 19258a8
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions Code/Plots/map_monthly_dotplots_pcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ scale.max = max(c(DJF.cf1$pcp_in,MAM.cf1$pcp_in,JJA.cf1$pcp_in,SON.cf1$pcp_in,
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=-1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/map_monthly_dotplots_tmax.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ scale.max = max(c(DJF.cf1$mean,MAM.cf1$mean,JJA.cf1$mean,SON.cf1$mean,
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/map_monthly_dotplots_tmean.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ scale.max = max(c(DJF.cf1$mean,MAM.cf1$mean,JJA.cf1$mean,SON.cf1$mean,
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/map_monthly_dotplots_tmin.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ scale.max = max(c(DJF.cf1$mean,MAM.cf1$mean,JJA.cf1$mean,SON.cf1$mean,
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/maps_ts_plots_MAMSON.SWE.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/maps_ts_plots_SWE.precip.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/maps_ts_plots_max.SWE.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/maps_ts_plots_pcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=-1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/maps_ts_plots_soil.temp.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
3 changes: 2 additions & 1 deletion Code/Plots/maps_ts_plots_tmean.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)

# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=1, option = scale,
Expand Down
1 change: 1 addition & 0 deletions Code/Plots/maps_ts_plots_water.balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ scale.max = max(c(cf1$mean,cf2$mean,cf3$mean),na.rm=TRUE)
# ggplot
map.plot <- function(data, title,xaxis,metric,col){
ggplot() +
geom_raster(data = ak_df ,aes(x = x, y = y,alpha=HYP_HR_SR_W.1), show.legend=FALSE) +
geom_stars(data = data, alpha = 0.8) +
geom_sf(data = shp, aes(), fill = NA) +
scale_fill_viridis(direction=-1, option = scale,
Expand Down
20 changes: 15 additions & 5 deletions plot-creation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ knitr::opts_chunk$set(echo = TRUE)
```{r set directories, include=FALSE, results=hide, eval=TRUE}
rm(list = ls())
library(stars);library(dplyr);library(ggplot2);library(ggthemes);library(viridis);library(here);library(ggrepel);library(rlang);library(units); library(tidyr); library(lemon);library(ggpubr);library(gridExtra);library(grid); library(gtable); library(lubridate)
library(stars);library(dplyr);library(ggplot2);library(ggthemes);library(viridis);library(here);library(ggrepel);library(rlang);library(units); library(tidyr); library(lemon);library(ggpubr);library(gridExtra);library(grid); library(gtable); library(lubridate);library(raster)
base.dir = "C:/Users/achildress/Documents/wrst_temp"
data.dir = paste0(base.dir,"/Data")
Expand All @@ -22,6 +22,15 @@ boundary.dir <- "C:/Users/achildress/DOI/NPS-WRST-Resource Stewardship Strategy
wrst <- st_read(paste0(boundary.dir, "wrst_simple.shp")) # Wrangell Mountains
wrst <- st_transform(wrst, 3338)
# insert topo
topo <- stack(paste0(boundary.dir, 'HYP_HR_SR_W/HYP_HR_SR_W.tif')) # read in as stack so can see RBG layers
ext <- extent(-147, -139, 59.3, 63) # extent defined by lat/long
ak <- crop(topo, ext)
# plotRGB(ak)
ak2 <- projectRaster(ak, crs = CRS('+init=EPSG:3338')) # Alaska Albers
ak_df <- as.data.frame(ak2, xy = TRUE) # this step is important to get it to plot in ggplot
GCMs <- c("inmcm4.rcp85","ACCESS1-3.rcp45","CanESM2.rcp85")
CFs <- c("Climate Future 1", "Climate Future 2", "Climate Future 3")
cols <- c("#12045C","#ffcccc","#E10720")
Expand All @@ -35,10 +44,6 @@ CF_GCM <- data.frame(CF=CFs,GCM=GCMs,CF_col=cols)
```

```{r scatterplot, echo=FALSE, message=FALSE, warning=FALSE,eval=FALSE}
# source(here::here("Code", "Plots", "scatterplot.R"),echo = FALSE)
```

```{r seasonal plots, include=FALSE,results=hide, eval=TRUE}
dir = paste0(data.dir,"/WRST_simple/")
df = read.csv(paste0(dir,"/Monthly_met.csv"))
Expand Down Expand Up @@ -71,6 +76,11 @@ df.fut = subset(DF, Period=="Future" & GCM %in% GCMs)
delta = df.hist[,1:4]
delta[,5:8] = df.fut[,5:8] - df.hist[,5:8]
# source(here::here("Code", "Plots", "scatterplot.R"),echo = FALSE)
```

```{r seasonal plots, include=FALSE,results=hide, eval=TRUE}
source(here::here("Code", "Plots", "map_monthly_dotplots_tmax.R"),echo = FALSE)
source(here::here("Code", "Plots", "map_monthly_dotplots_tmin.R"),echo = FALSE)
source(here::here("Code", "Plots", "map_monthly_dotplots_tmean.R"),echo = FALSE)
Expand Down

0 comments on commit 19258a8

Please sign in to comment.