Importing flow data from the Environment Agency (EA) Hydrology Data Explorer (HDE)
import_hde.Rd
This function retrieves daily mean flow data from the EA's hydrology data explorer (HDE) for a user-defined set of sites (gauging stations). Date can be optionally filtered by date.
Usage
import_hde (sites, start_date = "1985-01-01", end_date = Sys.Date())
Arguments
- sites
Vector of site (station) IDs to filter by. NAs and blanks ("") are ignored.
- start_date
Start date for flow data extraction (YYYY-MM-DD format); Default = 01/01/1985.
- end_date
End date for flow data extraction (YYYY-MM-DD format); Default = today's date.
Value
A tibble containing daily flow data for the specified sites, with the following columns: flow_site_id, date, flow (in m3/s) and quality.
Details
This function provides access to Environment Agency open hydrology data via the Hydrology Data Explorer (https://environment.data.gov.uk/hydrology/).
The function initially imports flow data for all dates and then filters out records that are before start_date or after end_date. If the data does not span the entire range of dates provided, additional records are created and the flow and quality values defined as NA on these dates.
A warning message is produced for every site that cannot be found on HDE.
If a site ID is duplicated in the 'sites' argument, that site is only searched for once and a warning message is produced.
Examples
# Import data for selected sites and dates
# import_hde(sites = c("F1707", "030028"), start_date = "2000-01-01", end_date = "2019-12-31")
# Returns flow = NA if site exists but no data available for the specified date range
# import_hde(sites = c("F1707"), start_date = "1900-01-01", end_date = "1900-01-05")
# Returns data only for sites that are present in NRFA; see warning messages for missing sites
# import_hde(sites = c("F1707", "hello"), start_date = "2010-01-01", end_date = "2010-01-05")
# Returns an error if none of the sites are present in HDE
# import_hde(sites = c("hello", "hello2"))