README.md

rainfallR

Installation

gitlab

# the paths to the public and private ssh-key
public = "C://PATH/TO/PUBLIC/id_rsa.pub",
private = "C://PATH/TO/PRIVATE/id_rsa"

creds = git2r::cread_ssh_key(public, private)

# install it using devtools
devtools::install_git("git@gitlab.inf.unibz.it:proslide/rainfallR.git",
                      credentials = creds)

github

remotes::install_github("RobinKohrs/rainfallR")

Main Functionalities

In order for this to work, the data needs to be organisd in a specific structure, that is more or less like this:

PREC_GRIDS
├── 1980
│   ├── DAILYPCP_198001.nc
│   ├── DAILYPCP_198002.nc
│   ├── DAILYPCP_198003.nc
│   ├── DAILYPCP_198004.nc

Get access to single NetCDFs

data_path = "absolute_or_relative_path_to/PREC_GRIDs"
days_back = 1
day = as.Date("2009-01-20")
# will return:
# $`200901`
#[1] "absolute_or_relative_path_to/PREC_GRIDs2009/DAILYPCP_200901.nc"

Extract data of NetCDFs for Vector data

Point data

If we are interested in the extraction of rainfall for point data, a tyical workflow could look like this:

  1. get the landslide data

  2. here the iffitoR-package already comes with some prebuild dataset (landsld)

  3. Create a list of slides that happened on the same day in South Tyrol

  4. You can filter the landsld data according to your needs first

  5. And then run the function iffi10_same_day which returns a list. Each elemet in this list is a spatial dataframe with one or more slides that happened on the same day

  6. Extract the rainfall for those slides

  7. Now you can iterate over each element in the list and extract the rainfall for that date for those points. In this vignette one can find an approach to do this in parallel

Polygon data

For Polygon data we probably want to perform some kinf of aggregation. So the workflow might look a little different

  1. get the polygon data

  2. Something like the slope units, landslide polyons or catchments

  3. Find all the polygons that experienced landslides

  4. The function slide_dates_in_polygon returns one large dataframe where each row is one polygon that experienced at least one movement at a particular day. The column slides_per_poly_data contains the number of movements per day in that polygon.

  5. Extract the rainfall for each of the polygons

  6. The function get_rainfall_for_polygons now extracts in parallel the rainfall for the each polygon.

More help

Working with temperature data

data_path = "path_to_temperature_data"
spatial.obj = "path_to_polygons" # lets assume this is a polygon (e.g. a slope-unit)
fun = c("mean", "max")
date = as.Date("2020-01-01")
nc_var = "precipitation"
days_back = 7

res = ex_rainfall(data_oath=data_path, spatial.obj=spatial.obj, fun=fun, data=date, nc_var=nc_var, days_back=days_back)


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