# 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)
remotes::install_github("RobinKohrs/rainfallR")
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
PREC_GRIDS
├── 1980
│ ├── DAILYPCP_198001.nc
│ ├── DAILYPCP_198002.nc
│ ├── DAILYPCP_198003.nc
│ ├── DAILYPCP_198004.nc
get_nc_path
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"
If we are interested in the extraction of rainfall for point data, a tyical workflow could look like this:
get the landslide data
here the iffitoR
-package already comes with some prebuild dataset (landsld
)
Create a list of slides that happened on the same day in South Tyrol
You can filter the landsld
data according to your needs first
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
Extract the rainfall for those slides
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
For Polygon data we probably want to perform some kinf of aggregation. So the workflow might look a little different
get the polygon data
Something like the slope units, landslide polyons or catchments
Find all the polygons that experienced landslides
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.
Extract the rainfall for each of the polygons
The function get_rainfall_for_polygons
now extracts in parallel the rainfall for the each polygon.
As we have access to data about the temperature from 2000 to 2020 in almost the same format it was worth adapting the function slightly to also extract this data for points and polygons.
The funciton ex_rainfall
now also can work with temperature data. Therefore you only need to change the paramter passed to the nc_var
-argument. Instead of using the default: precipitation
, use temperature
.
The rest should stay the same. An Example function call could then look like this:
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.