tsFetch | R Documentation |
This script takes the data.table output from the stationMeta function (truncated if you desire fewer stations) and fetches time-series information for the stations contained in the "Site name", "Location identifier" columns present in the Excel workbook fed to stationMeta. The Data location column informs where this script looks for data, and entries there must correspond exactly to one of EQWin, Aquarius GW, Aquarius MET, Snow Survey Access, Workbook, WSC, or ECCC.
tsFetch( TS, sources = "all", AQlogin = Sys.getenv(c("AQUSER", "AQPASS"), names = FALSE), SnowSurveyPath = "X:/Snow/DB/SnowDB.mdb", EQWinPath = "X:/EQWin/WR/DB/Water Resources.mdb", HYlogin = NULL, WorkbookPath = NULL )
TS |
The data.table output of WRBTrends::stationMeta, containing at minimum the default columns specified by that function. |
sources |
The list of sources you wish to download data for. "all" means all the sources listed in the "Data location" column of the input data.table. Can also specify from "Aquarius GW", "Aquarius MET", "Aquarius HYDRO", "EQWin", "Snow Survey Access", "ECCC", or "Workbook" if you want to exclude any sources. If specifying "Workbook" all time-series must be in individual workbook tabs with columns "datetime" and "value". |
AQlogin |
The login parameters for Aquarius. Defaults to your .Renviron profile, in which the username and password should appear in key pairs of AQUSER="username" and AQPASS="password". You can also specify credentials in format c("username", "password"). Leave NULL if you are not fetching from Aquarius, in which case you should either ensure it is not specified in the input data.table or is excluded under the source parameter. |
SnowSurveyPath |
The exact path to the Snow Survey Access database. If specifying an Access database see the note below. |
EQWinPath |
The exact path to the EQWin access database. If specifying an Access database see the note below. |
HYlogin |
Currently not used. The login parameters for tidyhydat.ws in format c("username", "password"). |
WorkbookPath |
The exact path to the Excel workbook containing time-series information that you wish to analyze, if applicable. Each tab in the workbook (from 1 to n) should contain a single time-series, named as Location identifier TS name. Location identifier and TS name must EXACTLY match the entries in the Excel metadata workbook, separated by a space. |
BE AWARE that this function may take a long time to execute and might be RAM intensive, perform work on a computer with lots of memory and a good internet connection!
If you are fetching information from the EQWin or Snow Survey Access databases you MUST have access to the X drive on your machine. Aquarius, WSC, and ECCC data can be fetched from anywhere with an internet connection.
If you are using Access databases you will need to download and install the Microsoft Access Database Engine Redistributable on your machine. As of spring 2022 the latest version is here: https://www.microsoft.com/en-us/download/details.aspx?id=54920.
This will work fine if you have R and Access in 32 OR 64 bit versions. If that's not the case then the best way forward is to upgrade your R AND Office installations to 64 bit versions.
If you are specifying an Excel workbook with time-series, each tab in the workbook must contain a single time-series. The tab must be named as Location identifier TS name, with Location identifier and TS name EXACTLY matching the relevant entries in the Excel metadata workbook, separated by a space. The first column of each tab must contain a time/date information, the second tab must contain the corresponding value. The header must be on line 1 (column names are not important) with no empty lines.
The Snow Survey processing includes applying a correction factor to Hyland and Twin Creeks stations to harmonize the new stations with the old stations.
A list of lists (one list per Data location), each list containing one element (tibble) per time-series, with processing performed to standardize the time-series to one common format. Designed to act as input to the WRBTrends:: ???? and ???? functions.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.