An R package to Retrieve, Filter and Visualize Data from the UK National River Flow Archive

DOI Travis-CI Build Status AppVeyor Build Status Coverage Status

CRAN Status Badge CRAN Total Downloads CRAN Monthly Downloads

The UK National River Flow Archive serves daily streamflow data, spatial rainfall averages and information regarding elevation, geology, land cover and FEH related catchment descriptors.

There is currently an API under development that in future should provide access to the following services: metadata catalogue, catalogue filters based on a geographical bounding-box, catalogue filters based on metadata entries, gauged daily data for about 400 stations available in WaterML2 format, the OGC standard used to describe hydrological time series.

The information returned by the first three services is in JSON format, while the last one is an XML variant.

The RNRFA package aims to achieve a simpler and more efficient access to data by providing wrapper functions to send HTTP requests and interpret XML/JSON responses.

Installation

The stable version of the rnrfa package is available from CRAN:

Or you can install the development version from Github with devtools:

Now, load the rnrfa package:

library(rnrfa)

Examples

Retrieve information for all the stations in the catalogue

The R function that deals with the NRFA catalogue to retrieve the full list of monitoring stations is called catalogue(). The function, used with no inputs, requests the full list of gauging stations with associated metadata. The output is a dataframe containing one record for each station and as many columns as the number of metadata entries available.

The same function catalogue() can be used to filter stations based on a bounding box or any of the metadata entries.

Conversions of OS grid references

The only geospatial information contained in the list of station in the catalogue is the OS grid reference (column “gridRef”). The RNRFA package allows convenient conversion to more standard coordinate systems. The function “osg_parse()”, for example, converts the string to easting and northing in the BNG coordinate system (EPSG code: 27700), as in the example below:

The same function can also convert from BNG to latitude and longitude in the WSGS84 coordinate system (EPSG code: 4326) as in the example below.

osg_parse() also works with multiple references:

Time series data

The first column of the table “someStations” contains the id number. This can be used to retrieve time series data and convert waterml2 files to time series object (of class zoo).

The National River Flow Archive serves two types of time series data: gauged daily flow and catchment mean rainfall.

Catchment mean rainfall:

Gauged daily flow:

For more examples and details, please see the vignette.

Terms and Conditions

Please refer to the following Terms and Conditions for use of NRFA Data and disclaimer: http://nrfa.ceh.ac.uk/costs-terms-and-conditions

This package uses a non-public API which is likely to change. Package and functions herein are provided as is, without any guarantee.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Meta