import_nrfa | R Documentation |
The import_nrfa function downloads mean daily flow data from the NRFA for a user-defined set of sites (gauging stations). Data can be optionally filtered by date.
import_nrfa(sites, start_date = "1985-01-01", end_data = Sys.Date(), tidyup = TRUE)
sites |
Vector of site (station) IDs to extract data for. NAs and blanks ("") are ignored |
start_date |
Start date for flow data extraction (YYYY-MM-DD format). Default = "1985-01-01". |
end_date |
End date for flow data extraction (YYYY-MM-DD format). Default = today's date. |
tidyup |
Whether or not csv files downloaded by the function to the users working directory should be deleted afterwards. Default = TRUE. |
The National River Flow Archive (NRFA; http://nrfa.ceh.ac.uk) is the main archive of river flow data for the United Kingdom, and contains data from over 1500 gauging stations. This function downloads flow data from the NRFA as a series of CSV files, one per site, and collates them into a single data set.
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 NRFA.
If a site ID is duplicated in the 'sites' argument, that site is only searched for once and a warning message is produced.
A tibble containing daily flow data for the specified sites, with the following columns: flow-site_id, date, and flow (in m3/s). (The NRFA database does not contain information about the quality of the flow data.)
# Import data for selected sites and dates (and keep downloaded CSV files for inspection)
# import_nrfa(sites = c("1001", "2001"), start_date = "2000-01-01", end_date = "2019-12-31", tidyup = FALSE)
# Returns flow = NA if site exists but no data available for the specified date range
# import_nrfa(sites = c("1001"), 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_nrfa(sites = c("1001", "hello"), start_date = "2010-01-01", end_date = "2010-01-05")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.