Learn R Programming

WaterML (version 1.7.1)

AddValues: AddValues

Description

This function adds a table of data values to HydroServer Lite. The input must be a data.frame with Time and DataValue fields The Time field must be POSIXct format and DataValue must be numeric format it is also required to enter a valid SiteID, VariableID, SourceID, MethodID and QualityControlLevelID. New data values shall be inserted only if the SiteID, VariableID, SourceID, MethodID and QualityControlLevelID entries already exist in the HydroServer. NOTE: this only works with HydroServer Lite that implements the JSON API. you must specify a valid server url, user name, and password for the HydroServer. The examples here use the 'sandbox' HydroServer on http://worldwater.byu.edu/app/ with the username: admin and password: password.

Usage

AddValues(server, username, password, site, variable, methodID, sourceID, qualityControl, values)

Arguments

server
The URL of the web service ending with /services or with ?wsdl, for example: http://worldwater.byu.edu/app/index.php/default/services/cuahsi_1_1.asmx?wsdl alternatively you can specify the JSON API url like: http://worldwater.byu.edu/app/index.php/default/services/api/
username
The valid HydroServer Lite username, for example "admin"
password
The valid HydroServer Lite password, for example "password"
site
The valid SiteID
variable
The valid VariableID
methodID
The valid MethodID
sourceID
The valid SourceID
qualityControl
The valid QualityControlLevelID
values
The valid table of data values. This table must have the following columns: Time (POSIXct), DataValue (numeric).

Value

Status (the status showing if the values were added: OK or Error). If the status is Error, then the Error message with reason why the values could not be added is also shown.

Examples

Run this code
user <- "admin"
pass <- "password"
server <- "http://worldwater.byu.edu/app/index.php/default/services/cuahsi_1_1.asmx"
sourceID = 15
qualityID = 1
variableID = 43
siteID = 170
methodID = 10
random_times <- sort(Sys.time() + runif(3, 0, 10)*60)
random_values <- runif(3, 0, 100)
my_values <- data.frame(Time=random_times, DataValue=random_values)

status  <- AddValues(server, username=user, password=pass,
                     site=siteID, variable=variableID,
                     methodID=methodID, sourceID=sourceID,
                     qualityControl=qualityID, values=my_values)

Run the code above in your browser using DataLab