library(banqueHydro)

The two main functions of package banqueHydro are:

Their main arguments correspond to station code and starting (t1) and ending (t2) dates.

The station codes can be explored here.

For QTVAR (measures at varying time intervals), t1 and t2 correspond to date-time formatted as “dd/MM/year HH:mm”:

df_qtvar <- bh_get_qtvar(station="V2942010",
                         t1="05/02/2007 15:00",
                         t2="08/04/2007 18:00")
#> [1] "Collecting QTVAR data between times t1=05/02/2007 15:00 and t2=08/04/2007 18:00."

df_qtvar[1:10,]
#> # A tibble: 10 x 3
#>    station  Time                    Q
#>    <chr>    <dttm>              <dbl>
#>  1 V2942010 2007-02-05 15:00:00 112  
#>  2 V2942010 2007-02-05 15:03:00 112  
#>  3 V2942010 2007-02-05 16:12:00 116  
#>  4 V2942010 2007-02-05 19:12:00 119  
#>  5 V2942010 2007-02-06 04:33:00 117  
#>  6 V2942010 2007-02-06 05:15:00 112  
#>  7 V2942010 2007-02-06 05:45:00 104  
#>  8 V2942010 2007-02-06 06:51:00  92.3
#>  9 V2942010 2007-02-06 07:33:00  87.8
#> 10 V2942010 2007-02-06 08:00:00  86.2

For QJM (mean daily measures), t1 and t2 correspond to starting and ending years:

df_qjm <- bh_get_qjm(station="V2942010",
                     t1=2008,
                     t2=2010)
#> [1] "Collecting QJM data for year 2008."
#> [1] "Collecting QJM data for year 2009."
#> [1] "Collecting QJM data for year 2010."
df_qjm[1:10,]
#> # A tibble: 10 x 4
#>    station  Date          Qj Val  
#>    <chr>    <date>     <dbl> <chr>
#>  1 V2942010 2008-01-01  59.4 <NA> 
#>  2 V2942010 2008-01-02  88.4 <NA> 
#>  3 V2942010 2008-01-03 135   <NA> 
#>  4 V2942010 2008-01-04 120   <NA> 
#>  5 V2942010 2008-01-05  57.3 <NA> 
#>  6 V2942010 2008-01-06 286   <NA> 
#>  7 V2942010 2008-01-07 398   <NA> 
#>  8 V2942010 2008-01-08 378   <NA> 
#>  9 V2942010 2008-01-09 286   <NA> 
#> 10 V2942010 2008-01-10 276   <NA>

Please be aware that web-scraping is a resource-consuming process and that one should refrain from submitting very demanding or unnecessary/redundant queries. The functions of package banqueHydro include by default delays to ensure that the queries do not overload the banqueHydro servers. Due to these safeguards, the completion of the requests above can take quite a long time (a few minutes for each of the commands above). Hence, you should make sure to save the results of these queries as R objects first, and then as local files, for instance through:

saveRDS(df_qtvar,"df_qtvar.RDS")
saveRDS(df_qjm,"df_qjm.RDS")

The tables are then saved as R data structures which you can later read with:

readRDS("df_qtvar.RDS")
readRDS("df_qjm.RDS")