Files downloaded from Centre d'Expertise Hydrique du Québec (CEHQ) are messy. The header contains useful information, but this information is not well organised. The table with values appears a couple of lines below the header. In this project, we share some functions that we've written to allow downloading, importing, tidying and visualizing flow data from CEHQ website.
Disclaimer : The authors are not affiliated to any govermental organizations.
See R script R/s1_data_download.R
for a complete example.
# Fetch stations.
stns <- fetch_stns(1L) # Id of the region.
# Download stations.
download_stns_files(stns$No_de_la_station)
See R script R/s2_import_and_plot_data.R
for an example.
# Load table.
tbl <- read_table(path)
# Load station information.
info <- read_info(path)
# Plot full series.
plot_flow_series(tbl, info)
# Plot series with NA.
plot_flow_series(tbl, info, spot.na = TRUE)
# Plot subset of the series.
plot_flow_series(tbl, info, start = "2018/01/01", end = "2020/12/13")
# Plot POT.
plot_flow_pot(tbl, info, thresh = quantile(tbl$FLOW, 0.99))
See R script R/s3_explore_missings.R
for an example.
# To be completed...
Enjoy ! ✌🏻