Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
HydroPrepR
February 2015
For Software version 1.0.0.1
Authors:
Chapter 1: Introduction
The HydroPrepR software is composed of different modules, listed in the left frame of the interface,
as presented in Figure 1.
List of modules
In order to use the different available tools, based on the open source and statistical
environment R, an R Distribution with predefined libraries is required. The link to the R
Folder has to be defined in the interface frame (bottom-right, see Figure 1).
The R Distribution can be downloaded on the same page as the HydroPrepR software.
Proper installation can be achieved using following steps:
Download the R Distribution for HydroPrepR (example: R-3.1.2-CREALP-v1.zip).
Unzip the R Distribution folder and move it to an adequate folder1.
When opening HydroPrepR for the first time, the message showed in Figure 2 will
appear. Accept the message and define the folder containing the R Distribution.
In the bottom-left part of the interface (Figure 1), the button allows to check if a new
version of the sorftware is available.
R is a language and environment for statistical computing and graphics (R Development Core
Team, 2008). Different applications have been developed in the R environment and have
been inserted in HydroPrepR in order to achieve different tasks, presented hereafter.
1
For example in C:\opt
This module allows the user to compute the centres of gravity and the surface area of
catchments and subcatchments. The results of the analysis are saved in the shapefile as
additional attributes.
Procedure
Define all required fields
Launch the calculation by double clicking on the button Create. At the end of the
running, you can find the generated files in the selected output directory.
Input data
Shapefile: ESRI Shapefile of polygons in a projected Coordinate reference system
(CRS). Coordinates must be distance units, not angles.
Digital elevation data: (optional) used to compute the average elevation of each
polygon. There must be at least one data point in each polygon for the algorithm to
function correctly. If no elevation data is provided, an elevation of zero is used as
default. The elevation data must be in the same CRS as the shapefile.
Output data
The result of the process is a shapefile of polygons to which four attributes have been added
to each feature:
X,Y,Z: the coordinates of the centre of gravity of each polygon
Surface: the surface area of each polygon
The Elevation Bands Creator tool allows the user to divide a shape representing a watershed
into a division of elevation bands. EB Creator produces a shape with the elevation bands and
a PDF file, but it also produces a parameter file with the necessary parameters for the
hydrological model.
EB Creator interface
To start EB Creator:
Click on the Elevation Bands Creator tab in the R Functions window (Figure 3). The EB
Creator is opened (Figure 4).
Outputs Launch
button
Data requirements
The following data files are required:
DEM of the entire basin. The grid must be regular. Various formats can be read by EB
Creator.
Shapefile of the basin (optionally divided with polygons into sub-basins). Each
polygon must contain a unique id field name. Polygons can be multipart features,
e.g. divided into more than one entity with the same id.
Shapefile of the glaciers, if the basin contains glaciers (optional).
Procedure
Hereafter, the necessary steps to perform a division of a watershed into multiple elevation
bands are presented.
In R apps, click on the module tool EB Creator.
Choose the DEM pathname in the inputs frame (by writing it or by double clicking to
indicate the location).
Choose the watershed shapefile pathname in the inputs frame (by writing it or by
double clicking to indicate the location).
Select the attribute to be used as id in the shapefile.
Indicate if there are glaciers. If it is the case, choose the glaciers shape pathname in
the inputs frame (by writing it or by double clicking to indicate the location).
Indicate the path where you want the outputs to be produced (in the outputs frame)
Indicate the outputs you want to be produced.
Define the maximum altitude difference in an elevation band by modifying the DELTA
Z MAX value.
Launch the calculation by double clicking on the button Create. At the end of the
running, you can find the asked files in the outputs directory.
It is important to ensure that no accent is present in the file and path names. If this is not
the case, errors might be generated during the calculation.
Furthermore, if the shapefile is of particularly big size and depending on the memory
capacity of the computer, it might run out of memory.
The data spatialization module (Figure 5) allows the user to generate a dataset of
interpolated stations that correspond to the topography of the users hydrological model.
Spatialization refers to two steps: interpolation and aggregation. Firstly, the time series of
precipitation, temperature, and / or evapotranspiration are estimated through interpolation
at each location of a grid of interpolation points. The interpolation points are automatically
positioned within the area of study defined by the shapefile of catchment polygons.
Then, if desired, the time series are aggregated by polygon: one average time series is
calculated for each polygon, based on the interpolation points contained in each polygon.
The average time series are each associated to a point at the centre of gravity of their
respective polygons.
Procedure
Define all required fields
Launch the calculation by double clicking on the button Create. At the end of the
running, you can find the generated files in the selected output directory.
Output
The module generates an RS dataset that can be directly opened in the program
RS MINERVE.
Procedure
The procedure followed by the module is represented in Figure 6.
Export data as
an RS dataset.
This is the simplest interpolation method for meteorological data, and uses the nearest
available elevation data (ED) point as a reference, without performing any further
adjustment on the data. The interpolated data at each time step thus has polygonial
structure (Figure 7).
Figure 7 Thiessen interpolation of measurement points (green) on interpolation points (other colours)
Method
The code is optimised for the situation in which the interpolation needs to be repeated
numerous times with almost identical2 data configurations.
1. First, a lookup table is generated that lists for each interpolation point the nearest
measurement stations available, for the sensor of interest (P, T and ETP). The
2
Alterations can occur if measurement points are missing.
DS.1
Thanks to this lookup table, the distances only need to be calculated once.
2. The program then loops through each time step and fetches for each interpolation
point the data value from the reference measurement station, indicated by the first
element of the lookup table for that station.
3. In the situation where one of the data points is missing, data from the next nearest
measurement stations is used.
It can be expected that this method runs faster than other interpolation methods.
In this method, the weights are proportional to the inverse power of the distance between
measurement stations and interpolation points. The user can choose between a power of 1
and a power of 2.
Method
For this method, the idw function from the gstat package (Pebesma, 2004) for R (R Core
Team, 2014) was used. The weight of the jth measurement station for the ith
interpolation point is given by:
DS.2
th
Where is the 2D distance as defined in 0. The data estimation at the i interpolation point is:
DS.3
th
Where is the data measurement at the j measurement station.
When, for a given interpolation point, all measurement stations are relatively far away, the
estimated value at the interpolation point tends towards the global average.
Kriging
For this method, the autokrige function from the automap package (Hiemstra, 2008) for R (R
Core Team, 2014) was used. This function automatically estimates the variogram and then
calls the krige function from the gstat package (Pebesma, 2004) to do the actual kriging.
DS.4
Where is an unknown constant. Documentation on kriging can be found in Cressie (1993).
Method
This method relies on a Gaussian filter to estimate the local elevation of a point. The
computation steps at each interpolation point are:
1. Calculate distance of ED points to the current interpolation point.
2. Calculate a weight for each ED point based on its distance. For this, a normal
distribution function with standard deviation equal to twice the interpolation grid cell
size is used. The weighting function used is:
DS.5
th th
Where is the weight of the j ED point for the i interpolation point, is the Euclidean distance
in 2D space between those two points, and is the minimum distance between interpolation points.
DS.6
As shown in the figures below, the use of a Gaussian filter smoothens the elevation
estimation in comparison to block sampling, where the elevation is estimated by averaging
DE data within a rectangular block around each interpolation point, thus introducing a
strong sampling effect.
Figure 8 Elevation estimation by block sampling Figure 9 Elevation estimation with a gaussian filter
Because the weighting function uses a standard deviation that is independent from the resolution of
the DE data, the method will not work if DE points are much sparser than interpolation points:
indeed, the weights rapidly fall to zero for all DE points further than from the interpolation
point.
4.3 Aggregation
Once the measured time series are interpolated at each interpolation point, the data is
aggregated: one time series is computed for each catchment. Each aggregated time series is
computed by averaging the data of all interpolation points situated within the boundaries of
each catchment (Figure 10). Each aggregated time series is associated to an interpolated
station located at the center of gravity of the corresponding polygon.
Figure 10 Mean aggregation of the interpolated temperature, by polygon. (left: interpolated data, right:
aggregation of interpolated data)
The CSV import module (Figure 11) allows the user to automatically generate an RS dataset
(dataset format for RS MINERVE software) with several stations and sensors from a CSV file,
thereby increasing processing speed and reducing the chance of errors occurring.
Procedure
Define all required fields
Launch the calculation by double clicking on the button Create. At the end of the
running, you can find the generated files in the selected output directory.
and either P, T, or ETP to indicate which sensor is represented by the time series,
separated by a colon (:) (Figure 12).
Column separator: The CSV files can use any character except a column to indicate
column breaks.
Data format: For each of P, T, and ETP, the user can select both the unit and the
interpolation mode that should be used when the data is interpreted in RS MINERVE.
Bibliography
Foehn, A., Garca Hernndez, J., Claude, A., Roquier, B., Boillat, J.-L. and Paredes Arquiola, J.
(2015). RS MINERVE Users manual v1.17. RS MINERVE Group, Switzerland.
Garca Hernndez, J., Paredes Arquiola, J., Foehn, A., Claude, A., Roquier, B. and Boillat, J.-L.
(2015). RS MINERVE Technical manual v 1.12. RS MINERVE Group, Switzerland.
Hiemstra, P.H., Pebesma, E.J., Twenhofel, C.J.W. and G.B.M. Heuvelink, (2008). Real-time
automatic interpolation of ambient gamma dose rates from the Dutch Radioactivity
Monitoring Network. Computers & Geosciences, accepted for publication.
Matheron, G, (1993). The Theory of Regionalized Variables and Its Applications. cole
national suprieure des mines, 211p.
Pebesma, E.J., (2004). Multivariable geostatistics in S: the gstat package. Computers &
Geosciences 30, 683-691.
R Development Core Team (2008). R: A language and environment for statistical computing.
R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0,
URL http://www.R-project.org
Acknowledgments
HydroPrepR is developed by the research center CREALP with the collaboration of the
Universitat Politcnica de Valncia and the Hydro10 Association.
We would like to thank sincerely these organizations for their support.
In addition, we would like to express our gratitude to the people who have personally
contributed to the improvement of the program and its documentation, in particular:
Stphane Micheloud1, Nestor Lerma2, Alex Dionisio-Calado1 and Samuel Alesina1.
Our gratitude also goes to the developers of all the complementary3 R packages used in
HydroPrepR, listed hereafter.
1
Centre de recherche sur lenvironnement alpin - CREALP
2
Universitat Politcnica de Valncia - UPV
3
The list excludes the following fundamental R packages: base, datasets, graphics, grDevices, grid, methods,
stats, utils.