The loadAPI function is used to interogate the EAs API. Data for all station can be pulled, or when specified to a single site various datasets can be pulled.
Usage
loadAPI(
ID = NULL,
measure = NULL,
period = NULL,
type = NULL,
datapoints = "standard",
from = NULL,
to = NULL,
lat = NULL,
long = NULL,
easting = NULL,
northing = NULL,
dist = NULL,
obsProperty = NULL,
meta = TRUE,
rtExt = FALSE,
rtLookup = FALSE
)
Arguments
- ID
Use to specify a particular WISKI ID or for when downloading all stations 'wiski' or 'nrfa' to filter results. Additionally to access the real time APIs use "flood" for all critical sites and "tidal" for the category A tide gauges.
- measure
Use this when exporting observations to select the available parameter. Generally 'flow', 'level', or 'groundwater'
- period
This is so you can select the time steps available, generally 900 (15 min) or 86400 (daily)
- type
Selects the data type, instantaneous, min, max etc.
- datapoints
Allows you to decide where in the time series you are pulling the data from
- from
First time step of choice
- to
Last time step of choice
- lat
Latitude coordinate for when searching by geographic area
- long
Longitude coordinate for when searching by geographic area
- easting
Easting coordinate for when searching by geographic area
- northing
Northing coordinate for when searching by geographic area
- dist
Distance in km for how far you wish to search
- obsProperty
Used to filter the stations when identifying sites. Available metrics; "waterFlow", "waterLevel", "rainfall", "groundwaterLevel", "wind", "temperature", "ammonium", "dissolved-oxygen", "conductivity", "ph", "temperature", "turbidity", "nitrate", "chlorophyll", "salinity", "bga", "fdom"
- meta
Set as TRUE, exports metadata for gauge with the data request
- rtExt
Set to NULL, if TRUE hydrological data series are extended with the real time API
- rtLookup
Set as FALSE, this uses an inbuilt dataset, if set to TRUE this will update the table using the most recent data. However, this can dramatically increase the run time.
Examples
#loadAPI()
loadAPI(easting = 378235, northing = 276165, dist = 30, ID = "nrfa")
#> wiskiID label riverName observedProperty easting northing
#> <char> <char> <char> <char> <int> <int>
#> 1: 2001 Bewdley River Severn waterLevel 378235 276165
#> 2: 2001 Bewdley River Severn waterFlow 378235 276165
#> 3: 2034 Oak Cottage Dowles Brook waterLevel 377105 276425
#> 4: 2034 Oak Cottage Dowles Brook waterFlow 377105 276425
#> 5: 2063 Prestwood River Stour waterFlow 386705 286155
#> 6: 2193 Wards Bridge Hadley Brook waterFlow 387025 263145
#> 7: 2011 Harford Hill River Salwarpe waterLevel 386865 261935
#> 8: 2011 Harford Hill River Salwarpe waterFlow 386865 261935
#> lat long dateOpened catchmentArea nrfaStationID
#> <num> <num> <char> <num> <char>
#> 1: 52.38307 -2.321186 1921-04-01 4325.0 54001
#> 2: 52.38307 -2.321186 1921-04-01 4325.0 54001
#> 3: 52.38536 -2.337805 1971-08-24 40.8 54034
#> 4: 52.38536 -2.337805 1971-08-24 40.8 54034
#> 5: 52.47315 -2.197148 1972-08-01 89.9 54063
#> 6: 52.26630 -2.191539 1987-12-10 53.0 54096
#> 7: 52.25542 -2.193836 1960-12-19 184.0 54011
#> 8: 52.25542 -2.193836 1960-12-19 184.0 54011
loadAPI(ID = "L1207")
#> measure period type
#> <char> <int> <char>
#> 1: level 86400 max
#> 2: level 86400 min
#> 3: level 900 instantaneous
loadAPI(
ID = "L1207",
measure = "level",
period = 900,
type = "instantaneous",
datapoints = "earliest"
)
#> ℹ Compiling parameters for raw download
#> ✔ Compiling parameters for raw download [134ms]
#>
#> ℹ Downloading raw data
#> ✔ Downloading raw data [104ms]
#>
#> ℹ Collating metadata
#> ✔ Collating metadata [234ms]
#>
#> ℹ Exporting data to HydroImport container
#> ✔ Exporting data to HydroImport container [41ms]
#>
#>
#> ── Class: HydroImport ──────────────────────────────────────────────────────────
#>
#> ── Metadata: ──
#>
#> Data Type: Raw Import
#> Station name: Todmorden Salford
#> WISKI ID: L1207
#> Parameter Type: Level
#> Modifications: NA
#> Start: 2003-03-09
#> End: 2003-03-09
#> Time Step: NA
#> Observations: 1
#> Easting: 393380
#> Northing: 423770
#> Longitude: -2.101764
#> Latitude: 53.710296
#>
#>
#> ── Observed data: ──
#>
#> dateTime value quality
#> <POSc> <num> <char>
#> 1: 2003-03-09 0.811 Good
#>
#>
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()
dt <- loadAPI(
ID = "L1207",
measure = "level",
period = 900,
type = "instantaneous",
datapoints = "all"
)
#> ℹ Compiling parameters for raw download
#> ✔ Compiling parameters for raw download [149ms]
#>
#> ℹ Downloading raw data
#> ✔ Downloading raw data [28.8s]
#>
#> ℹ Collating metadata
#> ✔ Collating metadata [210ms]
#>
#> ℹ Exporting data to HydroImport container
#> ✔ Exporting data to HydroImport container [21ms]
#>
with(dt$data, plot(value ~ dateTime,
type = "l",
xlab = "Time",
ylab = "Stage (mAoD)"
))