tidyhydat v0.5.0
Monthly downloads
Extract and Tidy Canadian 'Hydrometric' Data
Provides functions to access historical and real-time national 'hydrometric'
data from Water Survey of Canada data sources (<http://dd.weather.gc.ca/hydrometric/csv/> and
<http://collaboration.cmc.ec.gc.ca/cmc/hydrometrics/www/>) and then applies tidy data principles.
Readme
tidyhydat 
Project Status
This package is maintained by the Data Science and Analytics Branch of the British Columbia Ministry of Citizens’ Services.
What does tidyhydat
do?
- Provides functions (
hy_*
) that access hydrometric data from the HYDAT database, a national archive of Canadian hydrometric data and return tidy data. - Provides functions (
realtime_*
) that access Environment and Climate Change Canada’s real-time hydrometric data source. - Provides functions (
search_*
) that can search through the approximately 7000 stations in the database and aid in generating station vectors - Keep functions as simple as possible. For example, for daily flows,
the
hy_daily_flows()
function queries the database, tidies the data and returns a tibble of daily flows.
Installation
You can install tidyhydat
from CRAN:
install.packages("tidyhydat")
To install the development version of the tidyhydat
package, you need
to install the remotes
package then the tidyhydat
package:
if(!requireNamespace("remotes")) install.packages("remotes")
remotes::install_github("ropensci/tidyhydat")
Usage
A more thorough vignette can be found on the tidyhydat
CRAN
page.
When you install tidyhydat
, several other packages will be installed
as well. One of those packages, dplyr
, is useful for data
manipulations and is used regularly here. To use actually use dplyr
in
a session you must explicitly load it. A helpful dplyr
tutorial can be
found
here.
library(tidyhydat)
library(dplyr)
HYDAT download
To use many of the functions in the tidyhydat
package you will need to
download a version of the HYDAT database, Environment and Climate Change
Canada’s database of historical hydrometric data then tell R where to
find the database. Conveniently tidyhydat
does all this for you via:
download_hydat()
This downloads (with your permission) the most recent version of HYDAT
and then saves it in a location on your computer where tidyhydat
’s
function will look for it. Do be patient though as this can take a long
time! To see where HYDAT was saved you can run hy_default_db()
. Now
that you have HYDAT downloaded and ready to go, you are all set to begin
looking at Canadian hydrometric data.
Real-time
To download real-time data using the datamart we can use approximately
the same conventions discussed above. Using realtime_dd()
we can
easily select specific stations by supplying a station of interest:
realtime_dd(station_number = "08LG006")
#> Queried on: 2019-12-02 18:59:32 (UTC)
#> Date range: 2019-11-02 to 2019-12-02
#> # A tibble: 17,482 x 8
#> STATION_NUMBER PROV_TERR_STATE~ Date Parameter Value Grade
#> <chr> <chr> <dttm> <chr> <dbl> <chr>
#> 1 08LG006 BC 2019-11-02 08:00:00 Flow 13.6 <NA>
#> 2 08LG006 BC 2019-11-02 08:05:00 Flow 13.6 <NA>
#> 3 08LG006 BC 2019-11-02 08:10:00 Flow 13.6 <NA>
#> 4 08LG006 BC 2019-11-02 08:15:00 Flow 13.6 <NA>
#> 5 08LG006 BC 2019-11-02 08:20:00 Flow 13.6 <NA>
#> 6 08LG006 BC 2019-11-02 08:25:00 Flow 13.6 <NA>
#> 7 08LG006 BC 2019-11-02 08:30:00 Flow 13.6 <NA>
#> 8 08LG006 BC 2019-11-02 08:35:00 Flow 13.6 <NA>
#> 9 08LG006 BC 2019-11-02 08:40:00 Flow 13.6 <NA>
#> 10 08LG006 BC 2019-11-02 08:45:00 Flow 13.6 <NA>
#> # ... with 17,472 more rows, and 2 more variables: Symbol <chr>, Code <chr>
Plotting
Plot methods are also provided to quickly visualize realtime data:
realtime_ex <- realtime_dd(station_number = "08LG006")
plot(realtime_ex)
and also historical data:
hy_ex <- hy_daily_flows(station_number = "08LA001", start_date = "2013-01-01")
plot(hy_ex)
Getting Help or Reporting an Issue
To report bugs/issues/feature requests, please file an issue.
These are very welcome!
How to Contribute
If you would like to contribute to the package, please see our CONTRIBUTING guidelines.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Citation
Get citation information for tidyhydat
in R by running:
citation("tidyhydat")
License
Copyright 2017 Province of British Columbia
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Functions in tidyhydat
Name | Description | |
hy_plot | This function is deprecated in favour of generic plot methods | |
hy_stations | Extract station information from the HYDAT database | |
hy_stn_regulation | Extract station regulation from the HYDAT database | |
hy_monthly_flows | Extract monthly flows information from the HYDAT database | |
tidyeval | Tidy eval helpers | |
hy_daily_levels | Extract daily levels information from the HYDAT database | |
hy_stn_remarks | Extract station remarks from HYDAT database | |
hy_monthly_levels | Extract monthly levels information from the HYDAT database | |
tidyhydat-package | tidyhydat: Extract and Tidy Canadian 'Hydrometric' Data | |
hy_stn_data_coll | Extract station data collection from HYDAT database | |
hy_sed_daily_loads | Extract daily sediment load information from the HYDAT database | |
hy_sed_daily_suscon | Extract daily suspended sediment concentration information from the HYDAT database | |
hy_stn_data_range | Extract station data range from HYDAT database | |
plot | Plot historical and realtime data | |
hy_sed_monthly_suscon | Extract monthly flows information from the HYDAT database | |
hy_sed_monthly_loads | Extract monthly flows information from the HYDAT database | |
hy_stn_datum_conv | Extract station datum conversions from HYDAT database | |
hy_dir | Output OS-independent path to the HYDAT sqlite database | |
hy_sed_samples | Extract instantaneous sediment sample information from the HYDAT database | |
hy_datum_list | Extract datum list from HYDAT database | |
hy_sed_samples_psd | Extract instantaneous sediment sample particle size distribution information from the HYDAT database | |
realtime_dd | Download a tibble of realtime river data from the last 30 days from the Meteorological Service of Canada datamart | |
hy_stn_datum_unrelated | Extract station datum unrelated from HYDAT database | |
hy_test_db | Get the location of the HYDAT database | |
hy_stn_op_schedule | Extract station operation schedule from HYDAT database | |
hy_version | Extract version number from HYDAT database | |
realtime_plot | Convenience function to plot realtime data | |
pull_station_number | Convenience function to pull station number from tidyhydat functions | |
station_choice | Function to chose a station based on consistent arguments for hydat functions. | |
hy_reg_office_list | Extract regional office list from HYDAT database | |
hy_set_default_db | Set the default database path | |
search_stn_name | A search function for hydrometric station name or number | |
realtime_add_local_datetime | Add local datetime column to realtime tibble | |
hy_src | Open a connection to the HYDAT database | |
realtime_daily_mean | Calculate daily means from higher resolution realtime data | |
realtime_stations | Download a tibble of active realtime stations | |
reexports | Objects exported from other packages | |
allstations | All Canadian stations | |
hy_agency_list | hy_agency_list function | |
hy_annual_stats | Extract annual statistics information from the HYDAT database | |
hy_daily_flows | Extract daily flows information from the HYDAT database | |
hy_daily | Extract all daily water level and flow measurements | |
hy_data_symbols | DATA SYMBOLS look-up table | |
hy_annual_instant_peaks | Extract annual max/min instantaneous flows and water levels from HYDAT database | |
hy_data_types | DATA TYPES look-up table | |
download_hydat | Download and set the path to HYDAT | |
No Results! |
Vignettes of tidyhydat
Name | ||
tidyhydat_an_introduction.Rmd | ||
tidyhydat_example_analysis.Rmd | ||
tidyhydat_hydat_db.Rmd | ||
No Results! |
Last month downloads
Details
License | Apache License (== 2.0) | file LICENSE |
URL | https://docs.ropensci.org/tidyhydat/ |
BugReports | https://github.com/ropensci/tidyhydat/issues |
VignetteBuilder | knitr |
Encoding | UTF-8 |
LazyData | true |
RoxygenNote | 7.0.0 |
NeedsCompilation | no |
Packaged | 2019-12-02 19:03:12 UTC; SALBERS |
Repository | CRAN |
Date/Publication | 2019-12-02 20:20:03 UTC |
imports | cli (>= 1.0.0) , crayon (>= 1.3.4) , DBI (>= 0.7) , dbplyr (>= 1.1.0) , dplyr (>= 0.7.4) , httr (>= 1.3.1) , lubridate (>= 1.6.0) , rappdirs (>= 0.3.1) , readr (>= 1.1.1) , rlang (>= 0.1.2) , RSQLite (>= 2.0) , tidyr (>= 0.7.1) |
suggests | covr , ggplot2 , knitr , rmarkdown , testthat |
depends | R (>= 3.2.0) |
Contributors | Dewey Dunnington, Luke Winslow, Province of British Columbia, David Hutchinson, Laura DeCicco, Ryan Whaley |
Include our badge in your README
[](http://www.rdocumentation.org/packages/tidyhydat)