Title: | Extract and Tidy Canadian 'Hydrometric' Data |
---|---|
Description: | Provides functions to access historical and real-time national 'hydrometric' data from Water Survey of Canada data sources (<https://dd.weather.gc.ca/hydrometric/csv/> and <https://collaboration.cmc.ec.gc.ca/cmc/hydrometrics/www/>) and then applies tidy data principles. |
Authors: | Sam Albers [aut, cre] |
Maintainer: | Sam Albers <[email protected]> |
License: | Apache License (== 2.0) | file LICENSE |
Version: | 0.6.1 |
Built: | 2024-08-29 22:56:31 UTC |
Source: | https://github.com/ropensci/tidyhydat |
A shorthand to avoid having always call hy_stations
or realtime_stations
.
Populated by both realtime and historical data from HYDAT.
allstations
allstations
A tibble with 5 variables:
Unique 7 digit Water Survey of Canada station number
Official name for station identification
The province, territory or state in which the station is located
Current status of discharge or level monitoring in the hydrometric network
Logical. Indicates if a station has the capacity to deliver data in real-time or near real-time
North-South Coordinates of the gauging station in decimal degrees
East-West Coordinates of the gauging station in decimal degrees
Timezone of station calculated using the lutz package based on LAT/LONG of stations
Offset from UTC of local standard time
HYDAT, Meteorological Service of Canada datamart
Download the HYDAT sqlite database. This database contains all the historical hydrometric data for Canada's integrated hydrometric network. The function will check for a existing sqlite file and won't download the file if the same version is already present.
download_hydat(dl_hydat_here = NULL, ask = TRUE)
download_hydat(dl_hydat_here = NULL, ask = TRUE)
dl_hydat_here |
Directory to the HYDAT database. The path is chosen by the |
ask |
Whether to ask (as |
## Not run: download_hydat() ## End(Not run)
## Not run: download_hydat() ## End(Not run)
AGENCY look-up Table
hy_agency_list(hydat_path = NULL)
hy_agency_list(hydat_path = NULL)
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
A tibble of agencies
HYDAT
Other HYDAT functions:
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_agency_list() ## End(Not run)
## Not run: hy_agency_list() ## End(Not run)
Provides wrapper to turn the ANNUAL_INSTANT_PEAKS table in HYDAT into a tidy data frame of instantaneous flows and water levels.
station_number
and prov_terr_state_loc
can both be supplied.
hy_annual_instant_peaks( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_year = NULL, end_year = NULL )
hy_annual_instant_peaks( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_year = NULL, end_year = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_year |
First year of the returned record |
end_year |
Last year of the returned record |
A tibble of hy_annual_instant_peaks.
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: ## Multiple stations province not specified hy_annual_instant_peaks(station_number = c("08NM083", "08NE102")) ## Multiple province, station number not specified hy_annual_instant_peaks(prov_terr_state_loc = c("AB", "YT")) ## End(Not run)
## Not run: ## Multiple stations province not specified hy_annual_instant_peaks(station_number = c("08NM083", "08NE102")) ## Multiple province, station number not specified hy_annual_instant_peaks(prov_terr_state_loc = c("AB", "YT")) ## End(Not run)
Provides wrapper to turn the ANNUAL_STATISTICS table in HYDAT into a tidy data frame of annual statistics. Statistics provided include MEAN, MAX and MIN on an annual basis.
hy_annual_stats( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_year = "ALL", end_year = "ALL" )
hy_annual_stats( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_year = "ALL", end_year = "ALL" )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_year |
First year of the returned record |
end_year |
Last year of the returned record |
A tibble with 8 variables:
Unique 7 digit Water Survey of Canada station number
Parameter being measured. Only possible values are FLOW and LEVEL
Year of record.
Summary statistic being used.
Value of the measurement. If Parameter equals FLOW the units are m^3/s. If Parameter equals LEVEL the units are metres.
Observation date. Formatted as a Date class. MEAN is a annual summary and therefore has an NA value for Date.
Measurement/river conditions
A tibble of hy_annual_stats.
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: ## Multiple stations province not specified hy_annual_stats(station_number = c("08NM083", "05AE027")) ## Multiple province, station number not specified hy_annual_stats(prov_terr_state_loc = c("AB", "SK")) ## End(Not run)
## Not run: ## Multiple stations province not specified hy_annual_stats(station_number = c("08NM083", "05AE027")) ## Multiple province, station number not specified hy_annual_stats(prov_terr_state_loc = c("AB", "SK")) ## End(Not run)
A thin wrapper around hy_daily_flows
and 'hy_daily_levels“ that returns a data frames that
contains both parameters. All arguments are passed directly to these functions.
hy_daily( station_number = NULL, prov_terr_state_loc = NULL, hydat_path = NULL, ... )
hy_daily( station_number = NULL, prov_terr_state_loc = NULL, hydat_path = NULL, ... )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
... |
See |
A tibble with 5 variables:
Unique 7 digit Water Survey of Canada station number
Observation date. Formatted as a Date class.
Parameter being measured.
Discharge value. The units are m^3/s.
Measurement/river conditions
A tibble of daily flows and levels
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_daily(station_number = c("02JE013", "08MF005")) ## End(Not run)
## Not run: hy_daily(station_number = c("02JE013", "08MF005")) ## End(Not run)
Provides wrapper to turn the DLY_FLOWS table in HYDAT into a tidy data frame of daily flows.
station_number
and prov_terr_state_loc
can both be supplied. If both are omitted all
values from the hy_stations
table are returned. That is a large tibble for hy_daily_flows
.
hy_daily_flows( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL, symbol_output = "code" )
hy_daily_flows( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL, symbol_output = "code" )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
symbol_output |
Set whether the raw code, or the |
A tibble with 5 variables:
Unique 7 digit Water Survey of Canada station number
Observation date. Formatted as a Date class.
Parameter being measured. Only possible value is Flow
Discharge value. The units are m^3/s.
Measurement/river conditions
A tibble of daily flows
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: # download_hydat() hy_daily_flows( station_number = c("08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_daily_flows(prov_terr_state_loc = "PE") ## End(Not run)
## Not run: # download_hydat() hy_daily_flows( station_number = c("08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_daily_flows(prov_terr_state_loc = "PE") ## End(Not run)
Provides wrapper to turn the DLY_LEVELS table in HYDAT into a tidy data frame. The primary value returned by this
function is discharge. station_number
and prov_terr_state_loc
can both be supplied. If both are omitted all
values from the hy_stations
table are returned. That is a large vector for hy_daily_levels
.
hy_daily_levels( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL, symbol_output = "code" )
hy_daily_levels( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL, symbol_output = "code" )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
symbol_output |
Set whether the raw code, or the |
A tibble with 5 variables:
Unique 7 digit Water Survey of Canada station number
Observation date. Formatted as a Date class.
Parameter being measured. Only possible value is Level
Level value. The units are metres.
Measurement/river conditions
A tibble of daily levels
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_daily_levels( station_number = c("02JE013", "08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_daily_levels(prov_terr_state_loc = "PE") ## End(Not run)
## Not run: hy_daily_levels( station_number = c("02JE013", "08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_daily_levels(prov_terr_state_loc = "PE") ## End(Not run)
A look table for data symbols
hy_data_symbols
hy_data_symbols
A tibble with 5 rows and 3 variables:
Symbol code
Description of Symbol (English)
Description of Symbol (French)
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
A look table for data types
hy_data_types
hy_data_types
A tibble with 5 rows and 3 variables:
Data type code
Descriptive data type (English)
Descriptive data type (French)
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
DATUM look-up Table
hy_datum_list(hydat_path = NULL)
hy_datum_list(hydat_path = NULL)
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
A tibble of DATUMS
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_datum_list() ## End(Not run)
## Not run: hy_datum_list() ## End(Not run)
Provides the download location for download_hydat in an OS independent manner.
hy_dir(...)
hy_dir(...)
... |
arguments potentially passed to |
## Not run: hy_dir() ## End(Not run)
## Not run: hy_dir() ## End(Not run)
Tidy data of monthly flows information from the monthly_flows HYDAT table. station_number
and
prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned.
That is a large vector for hy_monthly_flows
.
hy_monthly_flows( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_monthly_flows( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 8 variables:
Unique 7 digit Water Survey of Canada station number
Year of record.
Numeric month value
Logical value is there is full record from Month
Number of days in that month
Summary statistic being used.
Value of the measurement in m^3/s.
Observation date. Formatted as a Date class. MEAN is a annual summary and therefore has an NA value for Date.
A tibble of monthly flows.
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_monthly_flows( station_number = c("02JE013", "08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_monthly_flows(prov_terr_state_loc = "PE") ## End(Not run)
## Not run: hy_monthly_flows( station_number = c("02JE013", "08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_monthly_flows(prov_terr_state_loc = "PE") ## End(Not run)
Tidy data of monthly river or lake levels information from the DLY_LEVELS HYDAT table. station_number
and
prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned.
That is a large vector for hy_monthly_levels
.
hy_monthly_levels( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_monthly_levels( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 8 variables:
Unique 7 digit Water Survey of Canada station number
Year of record.
Numeric month value
Logical value is there is full record from Month
Number of days in that month
Summary statistic being used.
Value of the measurement in metres.
Observation date. Formatted as a Date class. MEAN is a annual summary and therefore has an NA value for Date.
A tibble of monthly levels.
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_monthly_levels( station_number = c("02JE013", "08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_monthly_levels(prov_terr_state_loc = "PE") ## End(Not run)
## Not run: hy_monthly_levels( station_number = c("02JE013", "08MF005"), start_date = "1996-01-01", end_date = "2000-01-01" ) hy_monthly_levels(prov_terr_state_loc = "PE") ## End(Not run)
This is an easy way to visualize a single station using base R graphics.
More complicated plotting needs should consider using ggplot2
. Inputting more
5 stations will result in very busy plots and longer load time. Legend position will
sometimes overlap plotted points.
hy_plot( station_number = NULL, Parameter = c("Flow", "Level", "Suscon", "Load") )
hy_plot( station_number = NULL, Parameter = c("Flow", "Level", "Suscon", "Load") )
station_number |
A (or several) seven digit Water Survey of Canada station number. |
Parameter |
Parameter of interest. Either "Flow" or "Level". |
OFFICE look-up Table
hy_reg_office_list(hydat_path = NULL)
hy_reg_office_list(hydat_path = NULL)
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
A tibble of offices
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_reg_office_list() ## End(Not run)
## Not run: hy_reg_office_list() ## End(Not run)
Retrieve the date of the HYDAT version available for download.
hy_remote()
hy_remote()
Provides wrapper to turn the SED_DLY_LOADS table in HYDAT into a tidy data frame of daily sediment load information.
station_number
and prov_terr_state_loc
can both be supplied. If both are omitted all values from the
hy_stations
table are returned. That is a large vector for hy_sed_daily_loads
.
hy_sed_daily_loads( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_sed_daily_loads( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 4 variables:
Unique 7 digit Water Survey of Canada station number
Observation date. Formatted as a Date class.
Parameter being measured. Only possible value is Load
Discharge value. The units are tonnes.
A tibble of daily suspended sediment loads
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_sed_daily_loads(prov_terr_state_loc = "PE") ## End(Not run)
## Not run: hy_sed_daily_loads(prov_terr_state_loc = "PE") ## End(Not run)
Provides wrapper to turn the SED_DLY_SUSCON table in HYDAT into a tidy data frame of daily suspended sediment concentration information.
station_number
and prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned. That is a large vector for hy_sed_daily_suscon
.
hy_sed_daily_suscon( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL, symbol_output = "code" )
hy_sed_daily_suscon( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL, symbol_output = "code" )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
symbol_output |
Set whether the raw code, or the |
A tibble with 5 variables:
Unique 7 digit Water Survey of Canada station number
Observation date. Formatted as a Date class.
Parameter being measured. Only possible value is Suscon
Discharge value. The units are mg/l.
Measurement/river conditions
A tibble of daily suspended sediment concentration
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_sed_daily_suscon(station_number = "01CE003") ## End(Not run)
## Not run: hy_sed_daily_suscon(station_number = "01CE003") ## End(Not run)
Tidy data of monthly loads information from the SED_DLY_LOADS HYDAT table. station_number
and
prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned.
That is a large vector for hy_sed_monthly_loads
.
hy_sed_monthly_loads( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_sed_monthly_loads( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 8 variables:
Unique 7 digit Water Survey of Canada station number
Year of record.
Numeric month value
Logical value is there is full record from Month
Number of days in that month
Summary statistic being used.
Value of the measurement in tonnes.
Observation date. Formatted as a Date class. MEAN is a annual summary and therefore has an NA value for Date.
A tibble of monthly sediment loads.
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_sed_monthly_loads(station_number = "01CE003") ## End(Not run)
## Not run: hy_sed_monthly_loads(station_number = "01CE003") ## End(Not run)
Tidy data of monthly suspended sediment concentration information from the SED_DLY_SUSCON HYDAT table. station_number
and
prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned.
That is a large vector for hy_sed_monthly_suscon
.
hy_sed_monthly_suscon( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_sed_monthly_suscon( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 8 variables:
Unique 7 digit Water Survey of Canada station number
Year of record.
Numeric month value
Logical value is there is full record from Month
Number of days in that month
Summary statistic being used.
Value of the measurement in mg/l.
Observation date. Formatted as a Date class. MEAN is a annual summary and therefore has an NA value for Date.
A tibble of monthly suspended sediment concentrations.
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_sed_monthly_suscon(station_number = "08MF005") ## End(Not run)
## Not run: hy_sed_monthly_suscon(station_number = "08MF005") ## End(Not run)
Provides wrapper to turn the hy_sed_samples table in HYDAT into a tidy data frame of instantaneous sediment sample information.
station_number
and prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned. That is a large vector for hy_sed_samples
.
hy_sed_samples( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_sed_samples( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 19 variables:
Unique 7 digit Water Survey of Canada station number
Contains the type of sampling method used in collecting sediment for a station
Contains the time to the nearest minute of when the sample was taken
Descriptive Sediment Sample Remark in English
An "E" symbol means the time is an estimate only
Contains the instantaneous discharge in cubic metres per second at the time the sample was taken
Indicates a condition where the daily mean has a larger than expected error
Contains the type of measurement device used to take the sample
The location on the cross-section of the river at which the single sediment samples are collected. If one of the standard locations is not used the distance in meters will be shown
Indicates sample location relative to the regular measurement cross-section or the regular sampling site
Contains the instantaneous water temperature in Celsius at the time the sample was taken
Contains the instantaneous concentration sampled in milligrams per litre
Depth 2 for split vertical depth integrating (m)
A tibble of instantaneous sediment samples data
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_sed_samples(station_number = "01CA004") ## End(Not run)
## Not run: hy_sed_samples(station_number = "01CA004") ## End(Not run)
Provides wrapper to turn the hy_sed_samples_psd table in HYDAT into a tidy data frame of instantaneous sediment sample
particle size distribution. station_number
and prov_terr_state_loc
can both be supplied. If both
are omitted all values from the hy_stations()
table are returned. That is a large vector for hy_sed_samples_psd
.
hy_sed_samples_psd( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
hy_sed_samples_psd( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL, start_date = NULL, end_date = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
start_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
end_date |
Leave blank if all dates are required. Date format needs to be in YYYY-MM-DD. Date is inclusive. |
A tibble with 5 variables:
Unique 7 digit Water Survey of Canada station number
Contains the type of sampling method used in collecting sediment for a station
Contains the time to the nearest minute of when the sample was taken
Particle size (mm)
Contains the percentage values for indicated particle sizes for samples collected
A tibble of sediment sample particle size data
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_sed_samples_psd(station_number = "01CA004") ## End(Not run)
## Not run: hy_sed_samples_psd(station_number = "01CA004") ## End(Not run)
For many reasons, it may be convenient to set the default database location to somewhere other than the global default. Users may wish to use a previously downloaded version of the database for reproducibility purposes, store hydat somewhere other than hy_dir().
hy_set_default_db(hydat_path = NULL)
hy_set_default_db(hydat_path = NULL)
hydat_path |
The path to the a HYDAT sqlite3 database file (e.g., hy_test_db) |
returns the previous value of hy_default_db.
## Not run: # set default to the test database hy_set_default_db(hy_test_db()) # get the default value hy_default_db() # set back to the default db location hy_set_default_db(NULL) ## End(Not run)
## Not run: # set default to the test database hy_set_default_db(hy_test_db()) # get the default value hy_default_db() # set back to the default db location hy_set_default_db(NULL) ## End(Not run)
This function gives low-level access to the underlying HYDAT database used by
other functions. Many of these tables are too large to load into memory,
so it is best to use dplyr to dplyr::filter()
them before using
dplyr::collect()
to read them into memory.
hy_src(hydat_path = NULL) hy_src_disconnect(src)
hy_src(hydat_path = NULL) hy_src_disconnect(src)
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
src |
A as returned by |
A SQLite DBIConnection
## Not run: library(dplyr) # src is a src_sqlite src <- hy_src(hydat_path = hy_test_db()) src_tbls(src) # to get a table, use dplyr::tbl() tbl(src, "STATIONS") # one you're sure the results are what you want # get a data.frame using collect() tbl(src, "STATIONS") %>% filter(PROV_TERR_STATE_LOC == "BC") %>% collect() # close the connection to the database hy_src_disconnect(src) ## End(Not run)
## Not run: library(dplyr) # src is a src_sqlite src <- hy_src(hydat_path = hy_test_db()) src_tbls(src) # to get a table, use dplyr::tbl() tbl(src, "STATIONS") # one you're sure the results are what you want # get a data.frame using collect() tbl(src, "STATIONS") %>% filter(PROV_TERR_STATE_LOC == "BC") %>% collect() # close the connection to the database hy_src_disconnect(src) ## End(Not run)
Provides wrapper to turn the hy_stations table in HYDAT into a tidy data frame of station information. station_number
and
prov_terr_state_loc
can both be supplied. If both are omitted all values from the hy_stations
table are returned. This
is the entry point for most analyses is tidyhydat as establish the stations for consideration is likely the first step in many
instances.
hy_stations( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stations( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 15 variables:
Unique 7 digit Water Survey of Canada station number
Official name for station identification
The province, territory or state in which the station is located
The identifier of the regional office responsible for the station. Links to hy_reg_office_list
Current status of discharge or level monitoring in the hydrometric network
Current status of sediment monitoring in the hydrometric network
North-South Coordinates of the gauging station in decimal degrees
East-West Coordinates of the gauging station in decimal degrees
The total surface area that drains to the gauge site (km^2)
The portion of the drainage basin that contributes runoff to the gauge site, calculated by subtracting any noncontributing portion from the gross drainage area (km^2)
Logical. Reference Hydrometric Basin Network station. The Reference Hydrometric Basin Network (RHBN) is a sub-set of the national network that has been identified for use in the detection, monitoring, and assessment of climate change.
Logical. Indicates if a station has the capacity to deliver data in real-time or near real-time
Unique ID of an agency that contributes data to the HYDAT database. The agency is non-WSC and non WSC funded
Unique ID of an agency that operates a hydrometric station
Unique ID for a datum
A tibble of stations and associated metadata
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: ## Multiple stations province not specified hy_stations(station_number = c("08NM083", "08NE102")) ## Multiple province, station number not specified hy_stations(prov_terr_state_loc = c("AB", "YT")) ## End(Not run)
## Not run: ## Multiple stations province not specified hy_stations(station_number = c("08NM083", "08NE102")) ## Multiple province, station number not specified hy_stations(prov_terr_state_loc = c("AB", "YT")) ## End(Not run)
hy_stn_data_coll look-up Table
hy_stn_data_coll( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stn_data_coll( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 6 variables:
Unique 7 digit Water Survey of Canada station number
The type of data
First year of use
Last year of use
The sampling method used in the collection of sediment data or the type of the gauge used in the collection of the hydrometric data
The schedule of station operation for the collection of sediment or hydrometric data
A tibble of hy_stn_data_coll
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_stn_data_coll(station_number = c("02JE013", "08MF005")) ## End(Not run)
## Not run: hy_stn_data_coll(station_number = c("02JE013", "08MF005")) ## End(Not run)
hy_stn_data_range look-up Table
hy_stn_data_range( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stn_data_range( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 6 variables:
Unique 7 digit Water Survey of Canada station number
Code for the type of data
Code for the type of instantaneous sediment data
First year of use
Last year of use
Number of years of data available in the HYDAT database
A tibble of hy_stn_data_range
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_stn_data_range(station_number = c("02JE013", "08MF005")) ## End(Not run)
## Not run: hy_stn_data_range(station_number = c("02JE013", "08MF005")) ## End(Not run)
hy_stn_datum_conv look-up Table
hy_stn_datum_conv( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stn_datum_conv( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 4 variables:
Unique 7 digit Water Survey of Canada station number
Identifying a datum from which water level is being converted
Identifying a datum to which water level is being converted
The conversion factor applied to water levels referred to one datum to obtain water levels referred to another datum
A tibble of hy_stn_datum_conv
## Not run: hy_stn_datum_conv(station_number = c("02JE013", "08MF005")) ## End(Not run)
## Not run: hy_stn_datum_conv(station_number = c("02JE013", "08MF005")) ## End(Not run)
hy_stn_op_schedule look-up Table
hy_stn_op_schedule( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stn_op_schedule( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 6 variables:
Unique 7 digit Water Survey of Canada station number
The type of data
Year of operation schedule
First month of use
Last month of use
A tibble of hy_stn_op_schedule
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_regulation()
,
hy_version()
## Not run: hy_stn_op_schedule(station_number = c("02JE013")) ## End(Not run)
## Not run: hy_stn_op_schedule(station_number = c("02JE013")) ## End(Not run)
Provides wrapper to turn the hy_stn_regulation table in HYDAT into a tidy data frame of station regulation.
station_number
and prov_terr_state_loc
can both be supplied. If both are omitted all values
from the hy_stations
table are returned.
hy_stn_regulation( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stn_regulation( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 4 variables:
Unique 7 digit Water Survey of Canada station number
First year of use
Last year of use
logical
A tibble of stations, years of regulation and the regulation status
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_version()
## Not run: ## Multiple stations province not specified hy_stn_regulation(station_number = c("08NM083", "08NE102")) ## Multiple province, station number not specified hy_stn_regulation(prov_terr_state_loc = c("AB", "YT")) ## End(Not run)
## Not run: ## Multiple stations province not specified hy_stn_regulation(station_number = c("08NM083", "08NE102")) ## Multiple province, station number not specified hy_stn_regulation(prov_terr_state_loc = c("AB", "YT")) ## End(Not run)
hy_stn_remarks look-up Table
hy_stn_remarks( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
hy_stn_remarks( station_number = NULL, hydat_path = NULL, prov_terr_state_loc = NULL )
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 4 variables:
Unique 7 digit Water Survey of Canada station number
Type of Remark
Year of the remark
Remark
A tibble of hy_stn_remarks
## Not run: hy_stn_remarks(station_number = c("02JE013", "08MF005")) ## End(Not run)
## Not run: hy_stn_remarks(station_number = c("02JE013", "08MF005")) ## End(Not run)
The full HYDAT database needs to be downloaded from download_hydat, but for testing
purposes, a small test database is included in this package. Use
hydat_path = hy_test_db()
in hy_* functions to explicitly use the test database;
use hydat_path = hy_downloaded_db()
to explicitly use the full, most recent
downloaded database (this is also the path returned by hy_default_db()
).
hy_test_db() hy_downloaded_db() hy_default_db()
hy_test_db() hy_downloaded_db() hy_default_db()
The file location of a HYDAT database.
## Not run: hy_test_db() hy_downloaded_db() hy_default_db() ## End(Not run)
## Not run: hy_test_db() hy_downloaded_db() hy_default_db() ## End(Not run)
A function to get version number of hydat
hy_version(hydat_path = NULL)
hy_version(hydat_path = NULL)
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
version number and release date
HYDAT
Other HYDAT functions:
hy_agency_list()
,
hy_annual_instant_peaks()
,
hy_annual_stats()
,
hy_daily_flows()
,
hy_daily_levels()
,
hy_daily()
,
hy_data_symbols
,
hy_data_types
,
hy_datum_list()
,
hy_monthly_flows()
,
hy_monthly_levels()
,
hy_reg_office_list()
,
hy_sed_daily_loads()
,
hy_sed_daily_suscon()
,
hy_sed_monthly_loads()
,
hy_sed_monthly_suscon()
,
hy_sed_samples_psd()
,
hy_sed_samples()
,
hy_stations()
,
hy_stn_data_coll()
,
hy_stn_data_range()
,
hy_stn_op_schedule()
,
hy_stn_regulation()
## Not run: hy_version() ## End(Not run)
## Not run: hy_version() ## End(Not run)
A tibble of parameter id codes and their corresponding explanation/description specific to the ECCC webservice
param_id
param_id
A tibble with 8 rows and 7 variables:
Numeric parameter code
Letter parameter code
Code name in English
Code name in French
Parameter units
This method plots either daily time series data from HYDAT or realtime data from the datamart. These plots are intended to be convenient and quick methods to visualize hydrometric data.
## S3 method for class 'hy' plot(x = NULL, ...) ## S3 method for class 'realtime' plot(x = NULL, Parameter = c("Flow", "Level"), ...)
## S3 method for class 'hy' plot(x = NULL, ...) ## S3 method for class 'realtime' plot(x = NULL, Parameter = c("Flow", "Level"), ...)
x |
Object created by either a hy_daily_* or realtime_dd data retrieval function |
... |
passed to |
Parameter |
Parameter of interest. Either "Flow" or "Level". Defaults to "Flow". |
plot(realtime)
: plot.realtime
## Not run: # One station fraser <- hy_daily_flows("08MF005") plot(fraser) ## End(Not run) ## Not run: # One station fraser_realtime <- realtime_dd("08MF005") plot(fraser_realtime) ## End(Not run)
## Not run: # One station fraser <- hy_daily_flows("08MF005") plot(fraser) ## End(Not run) ## Not run: # One station fraser_realtime <- realtime_dd("08MF005") plot(fraser_realtime) ## End(Not run)
This function mimics dplyr::pull
to avoid having to always type
dplyr::pull(STATION_NUMBER). Instead we can now take advantage of autocomplete.
This can be used with realtime_
and hy_
functions.
pull_station_number(.data)
pull_station_number(.data)
.data |
A table of data |
A vector of station_numbers
## Not run: hy_stations(prov_terr_state_loc = "PE") %>% pull_station_number() %>% hy_annual_instant_peaks() ## End(Not run)
## Not run: hy_stations(prov_terr_state_loc = "PE") %>% pull_station_number() %>% hy_annual_instant_peaks() ## End(Not run)
Adds local_datetime
and tz_used
columns based on either the most common timezone in the original data or
a user supplied timezone. This function is meant to used in a pipe with the realtime_dd()
function.
realtime_add_local_datetime(.data, set_tz = NULL)
realtime_add_local_datetime(.data, set_tz = NULL)
.data |
Tibble created by |
set_tz |
A timezone string in the format of |
Date
from realtime_dd
is supplied in UTC which is the easiest format to work with across timezones. This function
does not change Date
from UTC. Rather station_tz
specifies the local timezone name and is useful in instances where
realtime_add_local_datetime
adjusts local_datetime to a common timezone that is not the station_tz
. This function is most
useful when all stations exist within the same timezone.
## Not run: realtime_dd(c("08MF005", "02LA004")) %>% realtime_add_local_datetime() ## End(Not run)
## Not run: realtime_dd(c("08MF005", "02LA004")) %>% realtime_add_local_datetime() ## End(Not run)
This function is meant to be used within a pipe as a means of easily moving from higher resolution data to daily means.
realtime_daily_mean(.data, na.rm = FALSE)
realtime_daily_mean(.data, na.rm = FALSE)
.data |
A data argument that is designed to take only the output of realtime_dd |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
## Not run: realtime_dd("08MF005") %>% realtime_daily_mean() ## End(Not run)
## Not run: realtime_dd("08MF005") %>% realtime_daily_mean() ## End(Not run)
Download realtime river data from the last 30 days from the Meteorological Service of Canada (MSC) datamart. The function will prioritize downloading data collected at the highest resolution. In instances where data is not available at high (hourly or higher) resolution daily averages are used. Currently, if a station does not exist or is not found, no data is returned.
realtime_dd(station_number = NULL, prov_terr_state_loc = NULL)
realtime_dd(station_number = NULL, prov_terr_state_loc = NULL)
station_number |
A seven digit Water Survey of Canada station number. If this argument is omitted, the value of |
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 8 variables:
Unique 7 digit Water Survey of Canada station number
The province, territory or state in which the station is located
Observation date and time for last thirty days. Formatted as a POSIXct class in UTC for consistency.
Parameter being measured. Only possible values are Flow and Level
Value of the measurement. If Parameter equals Flow the units are m^3/s. If Parameter equals Level the units are metres.
reserved for future use
reserved for future use
quality assurance/quality control flag for the discharge
Station timezone based on tidyhydat::allstations$station_tz
A tibble of water flow and level values. The date and time of the query (in UTC) is also stored as an attribute.
Other realtime functions:
realtime_stations()
,
realtime_ws()
## Not run: ## Download from multiple provinces realtime_dd(station_number = c("01CD005", "08MF005")) ## To download all stations in Prince Edward Island: pei <- realtime_dd(prov_terr_state_loc = "PE") ## Access the time of query attributes(pei)$query_time ## End(Not run)
## Not run: ## Download from multiple provinces realtime_dd(station_number = c("01CD005", "08MF005")) ## To download all stations in Prince Edward Island: pei <- realtime_dd(prov_terr_state_loc = "PE") ## Access the time of query attributes(pei)$query_time ## End(Not run)
This is an easy way to visualize a single station using base R graphics.
More complicated plotting needs should consider using ggplot2
. Inputting more
5 stations will result in very busy plots and longer load time. Legend position will
sometimes overlap plotted points.
realtime_plot(station_number = NULL, Parameter = c("Flow", "Level"))
realtime_plot(station_number = NULL, Parameter = c("Flow", "Level"))
station_number |
A seven digit Water Survey of Canada station number. Can only be one value. |
Parameter |
Parameter of interest. Either "Flow" or "Level". Defaults to "Flow". |
A plot of recent realtime values
## Not run: ## One station realtime_plot("08MF005") ## Multiple stations realtime_plot(c("07EC002", "01AD003")) ## End(Not run)
## Not run: ## One station realtime_plot("08MF005") ## Multiple stations realtime_plot(c("07EC002", "01AD003")) ## End(Not run)
An up to date dataframe of all stations in the Realtime Water Survey of Canada hydrometric network operated by Environment and Climate Change Canada
realtime_stations(prov_terr_state_loc = NULL)
realtime_stations(prov_terr_state_loc = NULL)
prov_terr_state_loc |
Province, state or territory. If this argument is omitted, the value of |
A tibble with 6 variables:
Unique 7 digit Water Survey of Canada station number
Official name for station identification
North-South Coordinates of the gauging station in decimal degrees
East-West Coordinates of the gauging station in decimal degrees
The province, territory or state in which the station is located
Timezone of the station
Other realtime functions:
realtime_dd()
,
realtime_ws()
## Not run: ## Available inputs for prov_terr_state_loc argument: unique(realtime_stations()$prov_terr_state_loc) realtime_stations(prov_terr_state_loc = "BC") realtime_stations(prov_terr_state_loc = c("QC", "PE")) ## End(Not run)
## Not run: ## Available inputs for prov_terr_state_loc argument: unique(realtime_stations()$prov_terr_state_loc) realtime_stations(prov_terr_state_loc = "BC") realtime_stations(prov_terr_state_loc = c("QC", "PE")) ## End(Not run)
Function to actually retrieve data from ECCC web service. The maximum number of days that can be queried depends on other parameters being requested. If one station is requested, 18 months of data can be requested. If you continually receiving errors when invoking this function, reduce the number of observations (via station_number, parameters or dates) being requested.
realtime_ws( station_number, parameters = NULL, start_date = Sys.Date() - 30, end_date = Sys.Date() )
realtime_ws( station_number, parameters = NULL, start_date = Sys.Date() - 30, end_date = Sys.Date() )
station_number |
Water Survey of Canada station number. |
parameters |
parameter ID. Can take multiple entries. Parameter is a numeric code. See |
start_date |
Accepts either YYYY-MM-DD or YYYY-MM-DD HH:MM:SS. If only start date is supplied (i.e. YYYY-MM-DD) values are returned from the start of that day. Defaults to 30 days before current date. Time is supplied in UTC. |
end_date |
Accepts either YYYY-MM-DD or YYYY-MM-DD HH:MM:SS. If only a date is supplied (i.e. YYYY-MM-DD) values are returned from the end of that day. Defaults to current date. Time is supplied in UTC. |
A tibble with 6 variables:
Unique 7 digit Water Survey of Canada station number
Observation date and time. Formatted as a POSIXct class as UTC for consistency.
Code name in English
Value of the measurement.
Value units
future use
future use
future use
Numeric parameter code
Letter parameter code
Other realtime functions:
realtime_dd()
,
realtime_stations()
## Not run: ws_08 <- realtime_ws( station_number = c("08NL071", "08NM174"), parameters = c(47, 5) ) fivedays <- realtime_ws( station_number = c("08NL071", "08NM174"), parameters = c(47, 5), end_date = Sys.Date(), # today start_date = Sys.Date() - 5 # five days ago ) ## End(Not run)
## Not run: ws_08 <- realtime_ws( station_number = c("08NL071", "08NM174"), parameters = c(47, 5) ) fivedays <- realtime_ws( station_number = c("08NL071", "08NM174"), parameters = c(47, 5), end_date = Sys.Date(), # today start_date = Sys.Date() - 5 # five days ago ) ## End(Not run)
Use this search function when you only know the partial station name or want to search.
search_stn_name(search_term, hydat_path = NULL) search_stn_number(search_term, hydat_path = NULL)
search_stn_name(search_term, hydat_path = NULL) search_stn_number(search_term, hydat_path = NULL)
search_term |
Only accepts one word. |
hydat_path |
The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call. |
A tibble of stations that match the search_term
## Not run: search_stn_name("Cowichan") search_stn_number("08HF") ## End(Not run)
## Not run: search_stn_name("Cowichan") search_stn_number("08HF") ## End(Not run)