Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update description #53

Merged
merged 19 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Package: wateRinfo
Title: Download Time Series Data from Waterinfo.be
Version: 0.3.0.9047
Description: The wateRinfo package provides an R interface to the data available
at waterinfo.be, the data portal provided by the Flemish Environmental
Agency. The package provides R functions to check the available stations for
a given variable, check the available variable for a given station and
download time series using the database identifiers as well as station
names.
Description: wateRinfo facilitates access to waterinfo.be
(<https://www.waterinfo.be>), a website managed by the Flanders Environment
Agency (VMM) and Flanders Hydraulics Research. The website provides access
to real-time water and weather related environmental variables for Flanders
(Belgium), such as rainfall, air pressure, discharge, and water level. The
package provides functions to search for stations and variables, and
download time series.
Authors@R: c(
person("Stijn", "Van Hoey", role = c("aut", "cre"), email = "stijn.vanhoey@inbo.be", comment = c(ORCID = "0000-0001-6413-3185")),
person("Willem", "Maetens", role = "ctb", email = "w.maetens@vmm.be"),
Expand Down
13 changes: 6 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file and knit -->

```{r, echo = FALSE}
Expand All @@ -16,13 +12,16 @@ knitr::opts_chunk$set(

[![Build Status](https://travis-ci.org/ropensci/wateRinfo.svg?branch=addci)](https://travis-ci.org/ropensci/wateRinfo) [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/5ia9va0jyskbvhev/branch/master?svg=true)](https://ci.appveyor.com/project/ropensci/waterinfo/branch/master) [![Coverage Status](https://coveralls.io/repos/github/ropensci/wateRinfo/badge.svg)](https://coveralls.io/r/ropensci/wateRinfo?branch=master)

The goal of wateRinfo is to facilitate access to the variety of environmental water-related data about Flanders (Belgium) available on [waterinfo.be](https://www.waterinfo.be/) by providing an R-interface to download time series data.
wateRinfo facilitates access to [waterinfo.be](https://www.waterinfo.be/), a website managed by the [Flanders Environment Agency (VMM)](https://en.vmm.be/) and [Flanders Hydraulics Research](https://www.waterbouwkundiglaboratorium.be/). The website provides access to real-time water and weather related environmental variables for Flanders (Belgium), such as rainfall, air pressure, discharge, and water level. The package provides functions to search for stations and variables, and download time series.

To get started, see:

An [API](https://www.waterinfo.be/download/9f5ee0c9-dafa-46de-958b-7cac46eb8c23?dl=0) is provided by waterinfo.be to request time series data. However, this still requires the proper composition of the URL with the identification codes (`Timeseriesgroup_id` and `ts_id`) as used by the system itself. To facilitate the user in searching for stations and variables and consequently download the data of interest, this package provides some general R functions to download the `waterinfo.be` data.
* [Function reference](https://ropensci.github.io/wateRinfo/reference/index.html): an overview of all wateRinfo functions.
* [Articles](https://ropensci.github.io/wateRinfo/articles/): tutorials on how to use the package.

## Installation

You can install wateRinfo from GitHub with:
You can install wateRinfo from [GitHub](https://github.com/ropensci/wateRinfo) with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
Expand Down
150 changes: 59 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,43 @@

<!-- README.md is generated from README.Rmd. Please edit that file and knit -->



# wateRinfo <img src="man/figures/logo.png" align="right" alt="" width="120">

[![Build
Status](https://travis-ci.org/ropensci/wateRinfo.svg?branch=addci)](https://travis-ci.org/ropensci/wateRinfo)
[![AppVeyor Build
status](https://ci.appveyor.com/api/projects/status/5ia9va0jyskbvhev/branch/master?svg=true)](https://ci.appveyor.com/project/ropensci/waterinfo/branch/master)
[![Coverage
Status](https://coveralls.io/repos/github/ropensci/wateRinfo/badge.svg)](https://coveralls.io/r/ropensci/wateRinfo?branch=master)

The goal of wateRinfo is to facilitate access to the variety of
environmental water-related data about Flanders (Belgium) available on
[waterinfo.be](https://www.waterinfo.be/) by providing an R-interface to
download time series data.

An
[API](https://www.waterinfo.be/download/9f5ee0c9-dafa-46de-958b-7cac46eb8c23?dl=0)
is provided by waterinfo.be to request time series data. However, this
still requires the proper composition of the URL with the identification
codes (`Timeseriesgroup_id` and `ts_id`) as used by the system itself.
To facilitate the user in searching for stations and variables and
consequently download the data of interest, this package provides some
general R functions to download the `waterinfo.be` data.
[![Build Status](https://travis-ci.org/ropensci/wateRinfo.svg?branch=addci)](https://travis-ci.org/ropensci/wateRinfo) [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/5ia9va0jyskbvhev/branch/master?svg=true)](https://ci.appveyor.com/project/ropensci/waterinfo/branch/master) [![Coverage Status](https://coveralls.io/repos/github/ropensci/wateRinfo/badge.svg)](https://coveralls.io/r/ropensci/wateRinfo?branch=master)

wateRinfo facilitates access to [waterinfo.be](https://www.waterinfo.be/), a website managed by the [Flanders Environment Agency (VMM)](https://en.vmm.be/) and [Flanders Hydraulics Research](https://www.waterbouwkundiglaboratorium.be/). The website provides access to real-time water and weather related environmental variables for Flanders (Belgium), such as rainfall, air pressure, discharge, and water level. The package provides functions to search for stations and variables, and download time series.

To get started, see:

* [Function reference](https://ropensci.github.io/wateRinfo/reference/index.html): an overview of all wateRinfo functions.
* [Articles](https://ropensci.github.io/wateRinfo/articles/): tutorials on how to use the package.

## Installation

You can install wateRinfo from GitHub with:
You can install wateRinfo from [GitHub](https://github.com/ropensci/wateRinfo) with:


``` r
```r
# install.packages("devtools")
devtools::install_github("ropensci/wateRinfo")
```

When succesfull, load it as usual:

``` r

```r
library(wateRinfo)
```

## Example

For a number of supported variables
([documented](https://www.waterinfo.be/download/9f5ee0c9-dafa-46de-958b-7cac46eb8c23?dl=0)
by VMM), the stations providing time series data for a given variable
can be listed with the command `get_stations`.
For a number of supported variables ([documented](https://www.waterinfo.be/download/9f5ee0c9-dafa-46de-958b-7cac46eb8c23?dl=0) by VMM), the stations providing time series data for a given variable can be listed with the command `get_stations`.

If you want to know the supported variables, ask for the supported
variables:
If you want to know the supported variables, ask for the supported variables:

``` r

```r
supported_variables("en")
#> variable_en
#> 1 discharge
Expand All @@ -72,9 +60,10 @@ supported_variables("en")
#> 41 wind_speed
```

Listing the available air\_pressure stations:
Listing the available air_pressure stations:


``` r
```r
get_stations("air_pressure")
#> ts_id station_latitude station_longitude station_id station_no
#> 1 78124042 51.20300 5.439589 12213 ME11_002
Expand Down Expand Up @@ -105,12 +94,10 @@ get_stations("air_pressure")
#> 8 hPa VMM
```

Each of the stations in the list for a given variable, are represented
by a `ts_id`. These can be used to download the data of a given period
with the command `get_timeseries_tsid`, for example Overpelt (`ts_id
= 78124042`):
Each of the stations in the list for a given variable, are represented by a `ts_id`. These can be used to download the data of a given period with the command `get_timeseries_tsid`, for example Overpelt (`ts_id = 78124042`):

``` r

```r
overpelt_pressure <- get_timeseries_tsid("78124042",
from = "2017-04-01",
to = "2017-04-02")
Expand All @@ -126,22 +113,21 @@ head(overpelt_pressure)

Making a plot of the data with ggplot:

``` r

```r
library(ggplot2)
ggplot(overpelt_pressure, aes(x = Timestamp, y = Value)) +
geom_line() +
xlab("") + ylab("hPa") +
scale_x_datetime(date_labels = "%H:%M\n%Y-%m-%d", date_breaks = "6 hours")
```

<img src="man/figures/README-plot_pressure-1.png" width="80%" />
<img src="man/figures/README-plot_pressure-1.png" title="plot of chunk showplot1" alt="plot of chunk showplot1" width="80%" />

Another option is to check the available variables for a given station, with the function `get_variables`. Let's consider again Overpelt (`ME11_002`) and check the first ten available variables at the Overpelt measurement station:

Another option is to check the available variables for a given station,
with the function `get_variables`. Let’s consider again Overpelt
(`ME11_002`) and check the first ten available variables at the Overpelt
measurement station:

``` r
```r
vars_overpelt <- get_variables("ME11_002")
head(vars_overpelt, 10)
#> station_name station_no ts_id ts_name parametertype_name
Expand All @@ -168,12 +154,10 @@ head(vars_overpelt, 10)
#> 10 WSpeed
```

Different pre-calculated variables are already available and a `ts_id`
value is available for each of them to download the corresponding data.
For example, `DagGem` (= daily mean values) of `RH` (= relative
humidity), i.e. `ts_id = 78382042`:
Different pre-calculated variables are already available and a `ts_id` value is available for each of them to download the corresponding data. For example, `DagGem` (= daily mean values) of `RH` (= relative humidity), i.e. `ts_id = 78382042`:

``` r

```r
overpelt_rh_daily <- get_timeseries_tsid("78382042",
from = "2017-04-01",
to = "2017-04-30")
Expand All @@ -187,69 +171,63 @@ head(overpelt_rh_daily)
#> 6 2017-04-06 23:00:00 82.71 130
```

``` r

```r
ggplot(overpelt_rh_daily, aes(x = Timestamp, y = Value)) +
geom_line() +
xlab("") + ylab(" RH (%)") +
scale_x_datetime(date_labels = "%b-%d\n%Y", date_breaks = "5 days")
```

<img src="man/figures/README-plot_rh-1.png" width="80%" />
<img src="man/figures/README-plot_rh-1.png" title="plot of chunk showplot2" alt="plot of chunk showplot2" width="80%" />

Unfortunately, not all variables are documented, for which the check for
the appropriate variable is not (yet) fully supported by the package.
Unfortunately, not all variables are documented, for which the check for the appropriate variable is not (yet) fully supported by the package.

More detailed tutorials are available in the package vignettes\!
More detailed tutorials are available in the package vignettes!

## Note on restrictions of the downloads

The amount of data downloaded from waterinfo.be is limited via a credit
system. You do not need to get a token right away to download data. For
limited and irregular downloads, a token will not be required.
The amount of data downloaded from waterinfo.be is limited via a credit system. You do not need to get a token right away to download data. For limited and irregular downloads, a token will not be required.

When you require more extended data requests, please request a download
token from the waterinfo.be site administrators via the e-mail adress
<hydrometrie@waterinfo.be> with a statement of which data and how
frequently you would like to download data. You will then receive a
client-credit code that can be used to obtain a token that is valid for
24 hours, after which the token can be refreshed with the same
client-credit code.
When you require more extended data requests, please request a download token from the waterinfo.be site administrators via the e-mail adress <hydrometrie@waterinfo.be> with a statement of which data and how frequently you would like to download data. You will then receive a client-credit code that can be used to obtain a token that is valid for 24 hours, after which the token can be refreshed with the same client-credit code.

Get token with client-credit code: (limited client-credit code for
testing
purposes)
Get token with client-credit code: (limited client-credit code for testing purposes)

``` r

```r
client <- paste0("MzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhOjRhZGE4",
"NzFhLTk1MjgtNGI0ZC1iZmQ1LWI1NzBjZThmNGQyZA==")
my_token <- get_token(client = client)
print(my_token)
#> Token:
#> eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1NjEwNTk1OS02OTRiLTQwYjEtOTdlYy04YTNhNzc0MjQ0MjUiLCJpYXQiOjE1NDQ3NDExMjEsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9LaVdlYlBvcnRhbC9hdXRoIiwiYXVkIjoiMzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhIiwiZXhwIjoxNTQ0ODI3NTIxfQ.15M1dSilAl7Ui_59wR5nWI9mQawJXZn6j_NFk_YUXYA
#> eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI3NjI2NzA4Yi0xNjdiLTRlZGMtOWI0OC01YmQ2MWY5ZDZmMmQiLCJpYXQiOjE1NTEyNzI4MjUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9LaVdlYlBvcnRhbC9hdXRoIiwiYXVkIjoiMzJkY2VlY2UtODI2Yy00Yjk4LTljMmQtYjE2OTc4ZjBjYTZhIiwiZXhwIjoxNTUxMzU5MjI1fQ.ySiyJdkmwFf-hy9hNAGqWFqWiAG18go7fFje3T_8uYE
#>
#> Attributes:
#> url: http://download.waterinfo.be/kiwis-auth/token
#> type: Bearer
#> expires: 2018-12-14 23:45:20 CET
#> expires: 2019-02-28 14:07:05 CET
```

Receive information on the validity of the token:

``` r

```r
is.expired(my_token)
#> [1] FALSE
```

Check when the token expires:

``` r

```r
expires.in(my_token)
#> Time difference of 24 hours
```

Use token when retrieving data:

``` r

```r
get_stations(variable_name = "verdamping_monteith", token = my_token)
#> ts_id station_latitude station_longitude station_id station_no
#> 1 94310042 51.02263 2.970584 12206 ME01_003
Expand Down Expand Up @@ -282,23 +260,13 @@ get_stations(variable_name = "verdamping_monteith", token = my_token)

## Acknowledgements

This package is just a small wrapper around waterinfo.be to facilitate
researchers and other stakeholders in downloading the data from
[waterinfo.be](http://www.waterinfo.be). The availability of this data
is made possible by *de Vlaamse Milieumaatschappij, Waterbouwkundig
Laboratorium, Maritieme Dienstverlening & Kust, Waterwegen en Zeekanaal
NV en De Scheepvaart NV*.
This package is just a small wrapper around waterinfo.be to facilitate researchers and other stakeholders in downloading the data from [waterinfo.be](http://www.waterinfo.be). The availability of this data is made possible by *de Vlaamse Milieumaatschappij, Waterbouwkundig Laboratorium, Maritieme Dienstverlening & Kust, Waterwegen en Zeekanaal NV en De Scheepvaart NV*.

## Meta

- We welcome [contributions](.github/CONTRIBUTING.md) including bug
reports.
- License: MIT
- Get citation information for `wateRinfo` in R doing
`citation("wateRinfo")`.
- Please note that this project is released with a [Contributor Code
of Conduct](.github/CODE_OF_CONDUCT.md). By participating in this
project you agree to abide by its
terms.

[![ropensci\_footer](https://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org)
* We welcome [contributions](.github/CONTRIBUTING.md) including bug reports.
* License: MIT
* Get citation information for `wateRinfo` in R doing `citation("wateRinfo")`.
* Please note that this project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

[![ropensci_footer](https://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org)
34 changes: 17 additions & 17 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
authors:
peterdesmet marked this conversation as resolved.
Show resolved Hide resolved
Stijn Van Hoey:
href: "https://twitter.com/SVanHoey"
Peter Desmet:
href: "https://twitter.com/peterdesmet"

home:
links:
- text: Visit waterinfo.be
href: https://www.waterinfo.be/
- text: Get to know our team
href: https://lifewatch.inbo.be

navbar:
title: ~
type: default
left:
- text: Reference
href: reference/index.html
- text: Tutorials
href: articles/index.html
menu:
- text: Definition of the date period to download
href: articles/define_date_periods.html
- text: Downloading time series in batch
href: articles/download_timeseries_batch.html
- text: Download time series from Waterinfo.be
- text: Download time series from waterinfo.be
href: articles/download_timeseries.html
- text: Functions
href: reference/index.html
- text: Contributing
href: CONTRIBUTING.html
right:
- icon: fa-twitter fa-lg
href: https://twitter.com/LifeWatchINBO
href: https://twitter.com/oscibio
- icon: fa-github fa-lg
href: https://github.com/ropensci/wateRinfo

home:
links:
- text: Visit Waterinfo.be
href: https://www.waterinfo.be/
- text: Get to know our team
href: https://lifewatch.inbo.be

authors:
Stijn Van Hoey:
href: https://twitter.com/SVanHoey
Peter Desmet:
href: https://twitter.com/peterdesmet

reference:
- title: "Main download functionalities"
desc: "Functions for downloading stations, variables and time series"
Expand Down
2 changes: 1 addition & 1 deletion vignettes/define_date_periods.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This vignette aims to briefly explain how to define the arguments.

## Which combinations?

In order to define a period, a start and end date is required. Defining all three will result in an error, but any combination of `from/to`, `from/period` and `to/period` is allowed. Moreover, if only `period` or `from` are defined, the Waterinfo.be API will automatically define `to` as the current time. Hence, defining *the last x days/months/years/...* can be achieved by only using the `period` option.
In order to define a period, a start and end date is required. Defining all three will result in an error, but any combination of `from/to`, `from/period` and `to/period` is allowed. Moreover, if only `period` or `from` are defined, the waterinfo.be API will automatically define `to` as the current time. Hence, defining *the last x days/months/years/...* can be achieved by only using the `period` option.

## How to define the from/to dates

Expand Down
Loading