knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(rainfallR)
library(stars)
library(sf)
os = ifelse(Sys.info()["sysname"] == "Windows", "w", "l")
if(os == "l"){
  path_ncdf = "/mnt/CEPH_PROJECTS/Proslide/PREC_GRIDS_updated/"
} else{
  path_ncdf = "\\\\projectdata.eurac.edu/projects/Proslide/PREC_GRIDS_updated/"
}

yearly_sums = aggregate_rainfall(
  path_ncdf = "/mnt/CEPH_PROJECTS/Proslide/PREC_GRIDS_updated/",
  polygon = NULL,
  years = 2015:2016,
  by = "year", # we only want the computed values for each year
  daily_fun = "sum",
  monthly_fun = "sum"
)
plot(yearly_sums)
mean_2k15_2k16 = st_apply(yearly_sums, c("x", "y"), mean)
plot(mean_2k15_2k16, main="Mean rainfall in the years 2015 and 2016")
# get the shape for South Tyrol
st = iffitoR::get_shape_southtyrol()
plot(st[0], add=T, col="red", lty=19)


RobinKohrs/rainfallR documentation built on Oct. 3, 2021, 1:42 a.m.