Package 'cde'

Title: Download Data from the Catchment Data Explorer Website
Description: Facilitates searching, download and plotting of Water Framework Directive (WFD) reporting data for all waterbodies within the UK Environment Agency area. The types of data that can be downloaded are: WFD status classification data, Reasons for Not Achieving Good (RNAG) status, objectives set for waterbodies, measures put in place to improve water quality and details of associated protected areas. The site accessed is <https://environment.data.gov.uk/catchment-planning/>. The data are made available under the Open Government Licence v3.0 <https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/>.
Authors: Rob Briers [aut, cre]
Maintainer: Rob Briers <[email protected]>
License: GPL-3
Version: 0.4.1.9004
Built: 2024-12-13 05:59:05 UTC
Source: https://github.com/ropensci/cde

Help Index


cde: Download Water Framework Directive (WFD) data from the Environment Agency Catchment Data Explorer (CDE) website.

Description

Facilitates searching and download of the WFD-related data for all waterbodies within the Environment Agency area (i.e. England). The types of data that can be downloaded are: WFD status classification data, Reasons for Not Achieving Good (RNAG) status, objectives set for waterbodies, and details of associated protected areas. Default plots can also be produced from thedata downloaded (form of plot depends on data type).

Details

The website that is accessed is: https://environment.data.gov.uk/catchment-planning/. The data accessed by and included within the package are made available under the Open Government Licence v3.0 https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/


Details of name and index of all sites/catchments.

Description

Dataframe used by 'cde' to construct API calls. The data included are made available under the Open Government Licence v3.0 https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/. Use of the data accessed by and contained within this package implies acceptance of these licence conditions.

Usage

ea_wbids

Format

A data frame with 5237 rows and 9 variables:

WBID

identifier for individual waterbodies

name

detailed name of the site/catchment

type

type of waterbody (River, Lake etc.)

OC

Operational Catchment name

OC_num

Index number of the Operational Catchment

MC

Management Catchment name

MC_num

Index number of the Management Catchment

RBD

River Basin District name

RBD_num

Index number of the River Basin District

For details of the hierarchy of the different catchment types, see https://environment.data.gov.uk/catchment-planning/help#help-catchment-hierarchy

Source

https://environment.data.gov.uk/catchment-planning/


Retrieve Objectives set for waterbodies

Description

Retrieves details of objectives set for waterbodies in terms of predicted classification from EA Catchment Data Explorer site. Data can be retrieved by specifying waterbody id (WBID), Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD). Start year (startyr) and end year (endyr) allow specific timeranges to be downloaded. For Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD) level downloads, waterbody type can also be specified to allow extraction of specific waterbody types (River, Lake etc).

Usage

get_objectives(
  ea_name = NULL,
  column = NULL,
  level = "Overall Water Body",
  year = NULL,
  type = NULL
)

Arguments

ea_name

A string representing the description (name for OC, MC or RBD level downloads or WBID for individual waterbodies) of the features to be extracted. For example to extract data for the whole of the Humber RBD, this would be "Humber"; also see examples. Must be an exact match to the values used in the EA database. Use the search_names function to search for specific values.

column

The column to be searched. Possible options are WBID (waterbody id), OC (Operational Catchment), MC (Management Catchment) and RBD (River Basin District)

level

The level within the WFD quality classification elements that objectives have been set at. For full details of the hierarchy of elements within the classification used, see https://environment.data.gov.uk/catchment-planning/help#help-classification-hierarchy.

Defaults to 'Overall Water Body'. Possible values for the different levels retrieved by the function are shown below.

Level 1 Level 2 Level 4
Ecological Biological quality elements Overall Water Body
Chemical Chemical Status element -
Quantitative Hydromorphological Supporting Elements -
- Other Substances -
- Physico-chemical quality elements -
- Priority hazardous substances -
- Priority substances -
- Quantitative Status element -
- Specific pollutants -
- Supporting elements -
year

The year that objectives are set for, either 2015, 2021, 2027, 2040 or 2050. If not given then objectives for all years are returned. Note that objectives may not be set for all years.

type

Type of waterbody to be extracted. For Operational/Management catchment level or RBD level queries, the data can also be subset by waterbody type. Possible values are River, Lake, GroundWaterBody, TransitionalWater or CoastalWater.

Value

An object of class cde_df containing the details of the objectives set for the specified set of waterbodies. For details of the meaning of the the different columns returned, see https://docs.ropensci.org/cde/articles/cde-output-reference.html.

Examples

# get all objectives set for waterbody GB112071065700
get_objectives(ea_name="GB112071065700", column="WBID")

# get the objectives set for Lakes in the Humber RBD, for the year 2021
get_objectives(ea_name="Humber", column="RBD", year=2021, type="Lake")

# get the objectives set for Rivers in the Avon Warwickshire
# Management Catchment in relation to Chemical status
get_objectives(ea_name="Avon Warwickshire", column="MC", level="Chemical", type="River")

Retrieve Protected Area Information

Description

Retrieves details of Protected Areas associated with waterbodies, catchments or River Basin Districts from the EA Catchment Data Explorer site. Data can be retrieved by specifying waterbody id (WBID), Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD).

Usage

get_pa(ea_name = NULL, column = NULL)

Arguments

ea_name

A string representing the description (name for OC, MC or RBD level downloads or WBID for individual waterbodies) of the features to be extracted. For example to extract data for the whole of the Humber RBD, this would be "Humber"; also see examples. Must be an exact match to the values used in the EA database. Use the search_names function to search for specific values.

column

The column to be searched. Possible options are WBID (waterbody id), OC (Operational Catchment), MC (Management Catchment) and RBD (River Basin District)

Value

An object of class cde_df containing the details of the Protected Areas associated with the waterbodies. For details of the meaning of the the different columns returned, see https://docs.ropensci.org/cde/articles/cde-output-reference.html.

Examples

# get protected areas associated with waterbody GB112071065700
get_pa(ea_name="GB112071065700", column="WBID")

# get the protected areas associated with the Humber RBD
get_pa(ea_name="Humber", column="RBD")

# get the protected areas associated with the Avon Warwickshire
# Management Catchment
get_pa(ea_name="Avon Warwickshire", column="MC")

Retrieve Reasons for Not Achieving Good Status

Description

Retrieves details of Reasons for Not Achieving Good (RNAG) status and Reasons For Failure (RFF) from EA Catchment Data Explorer site. Data can be retrieved by specifying waterbody id (WBID), Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD). Start year (startyr) and end year (endyr) allow specific timeranges to be downloaded. For Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD) level downloads, waterbody type can also be specified to allow extraction of specific waterbody types (River, Lake etc). Data are presented at the level of individual elements that are the reasons for not achieving good status.

Usage

get_rnag(ea_name = NULL, column = NULL, type = NULL)

Arguments

ea_name

A string representing the description (name for OC, MC or RBD level downloads or WBID for individual waterbodies) of the features to be extracted. For example to extract data for the whole of the Humber RBD, this would be "Humber"; also see examples. Must be an exact match to the values used in the EA database. Use the search_names function to search for specific values.

column

The column to be searched. Possible options are WBID (waterbody id), OC (Operational Catchment), MC (Management Catchment) and RBD (River Basin District)

type

Type of waterbody to be extracted. For Operational/Management catchment level or RBD level queries, the data can also be subset by waterbody type. Possible values are River, Lake, GroundWaterBody, TransitionalWater or CoastalWater.

Value

An object of class cde_df containing the details of the Reasons for Not Achieving Good Status for the specified combination of criteria. For details of the meaning of the the different columns returned, see https://docs.ropensci.org/cde/articles/cde-output-reference.html.

Examples

# get all RNAG issues identified for waterbody GB112071065700
get_rnag("GB112071065700", "WBID")

# get the RNAG issues for Lakes in the Humber RBD, between
# 2013 and 2014
get_rnag(ea_name="Humber", column="RBD", type="Lake")

# get the RNAG issues for Rivers in the Avon Warwickshire
# Management Catchment
get_rnag(ea_name="Avon Warwickshire", column="MC", type="River")

Retrieve WFD Status Classification Data

Description

Retrieves WFD Status classification data from EA Catchment Data Explorer site. Data can be retrieved by specifying waterbody id (WBID), Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD). Start year (startyr) and end year (endyr) allow specific timeranges to be downloaded. For Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD) level downloads, waterbody type can also be specified to allow extraction of specific waterbody types (River, Lake etc).

Usage

get_status(
  ea_name = NULL,
  column = NULL,
  level = "Overall Water Body",
  startyr = NULL,
  endyr = NULL,
  type = NULL
)

Arguments

ea_name

A string representing the description (name for OC, MC or RBD level downloads or WBID for individual waterbodies) of the features to be extracted. For example to extract data for the whole of the Humber RBD, this would be "Humber"; also see examples. Must be an exact match to the values used in the EA database. Use the search_names function to search for specific values.

column

The column to be searched. Possible options are WBID (waterbody id), OC (Operational Catchment), MC (Management Catchment) and RBD (River Basin District)

level

The level within the WFD quality classification elements that objectives have been set at. For full details of the hierarchy of elements within the classification used, see https://environment.data.gov.uk/catchment-planning/help/usage#catchment-hierarchy.

Defaults to 'Overall Water Body'. Possible values for the different levels retrieved by the function are shown below.

Level 1 Level 2 Level 4
Ecological Biological quality elements Overall Water Body
Chemical Chemical Status element -
Quantitative Hydromorphological Supporting Elements -
- Other Substances -
- Physico-chemical quality elements -
- Priority hazardous substances -
- Priority substances -
- Quantitative Status element -
- Specific pollutants -
- Supporting elements -
startyr

The data can be extracted for specific years using the startyr and endyr arguments. If only startyr is specified this extracts for a particular year. If no years are specified all years are returned.

endyr

The data can be extracted for specific years using the startyr and endyr arguments. The endyr should only be specified if startyr is also included, otherwise an error is returned.

type

Type of waterbody to be extracted. For Operational/Management catchment level or RBD level queries, the data can also be subset by waterbody type. Possible values are River, Lake, GroundWaterBody, TransitionalWater or CoastalWater.

Value

An object of class cde_df containing the classification details for the specified combination of criteria. For details of the meaning of the the different columns returned, see https://docs.ropensci.org/cde/articles/cde-output-reference.html.

Examples

# get Overall Water Body status classification for waterbody GB520804714300
get_status(ea_name="GB520804714300", column="WBID")

# get status class based on Priority substances for waterbody GB520804714300
get_status(ea_name="GB520804714300", column="WBID", level="Priority substances")

# get the Overall Water Body status of Lakes in the Humber RBD, between
# 2012 and 2014
get_status(ea_name="Humber", column="RBD", startyr=2012, endyr=2014, type="Lake")

# get the Overall Water Body status for Rivers in the Avon Warwickshire
# Operational Catchment in 2011
get_status(ea_name="Avon Warwickshire", column="MC", startyr=2011, type="River")

Plot method for cde_df output

Description

Default plots of the output main get_ functions. Details of the plots for different data are given below.

For status and objectives produces a (stacked) percentage barplot of waterbody observed or predicted (objective) status information for a given set of data.

For rnag, measures or pa produces a frequency histogram. The columns plotted for each data type are given below:

  • rnag (pressure_tier_3)

  • measures (measure_category_1)

  • pa (protected_area_type)

The full detail of the different data being plotted can be found in the EA Catchment Data Explorer API reference: https://environment.data.gov.uk/catchment-planning/ui/reference

Plotting is only possible for MC, OC or RBD downloads.

Usage

## S3 method for class 'cde_df'
plot(x, ...)

Arguments

x

An object of class cde_df to be plotted.

...

Other arguments passed on to individual methods. The only other argument implemented at present is scheme. For status and objectives data this defines which colour scheme to use with plots. It defaults to a viridis-based scheme (scheme="vir"). Alternatively, the colours specified in the WFD document can be used by specifying scheme="wfd".


Print method for cde_df

Description

Custom print method for objects of class cde_df. Formats output to fit current width of console, keeping full column names but truncating row values as required.

Usage

## S3 method for class 'cde_df'
print(x, ...)

Arguments

x

An object of class cde_df.

...

Other arguments passed on to individual methods. None implemented at present.


Search database of site names

Description

Searches the listing of EA monitoring sites to find rows that contain the string provided. Can search by WBID (WBID), name (name), Management Catchment (MC), Operational Catchment (OC) or River Basin District (RBD). There is a hierarchical relationship between these levels as shown at https://environment.data.gov.uk/catchment-planning/help#help-catchment-hierarchy.

The search is done on a local copy of the waterbody listing contained in the ea_wbids object rather than connecting to the EA site.

Usage

search_names(string = NULL, column = NULL)

Arguments

string

The search string to be matched (case-sensitive). Will match whole or partial strings in the column values.

column

The column to be searched. Possible options are WBID, name, OC (Operational Catchment), MC (Management Catchment) and RBD (River Basin District)

Value

A data frame containing the details of all the sites that match the search string (full or partial matches) in the column specified. Columns returned are defined in ea_wbids.

Examples

# search for sites containing "Tadnoll" in the name
search_names(string="Tadnoll", column="name")

# search for Operational Catchments containing "Cornwall"
search_names(string="Cornwall", column="OC")