provide_rain_data: Provide Rain Data for one Bathing Spot

Description Usage Arguments Value Examples

View source: R/provide_rain_data_for_bathing_spot.R

Description

The function considers (i) the "catchment" area that is defined for the bathing spot and (ii) the date range that is taken from the range of dates for which measurements are available. Rain data are read from binary Radolan files, masked around the "catchment" area and and averaged over all layears for each raster cell. The resulting rain data are then stored in the Postgres database. IMPORTANT: Existing rain data will be overwritten in the database!

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
provide_rain_data(
  user_id,
  spot_id,
  sampling_time = "1050",
  date_range = NULL,
  blocksize = 10,
  control = NULL,
  info = TRUE,
  urls = NULL
)

Arguments

user_id

user id

spot_id

bathing spot id

sampling_time

expected sampling time. Will be used to select the corresponding Radolan files.

date_range

vector of two Date objects giving the first and last day of rain data to be loaded. If NULL (the default) the range of dates is determined from the range of dates for which water quality measurements are available.

blocksize

number of Radolan files to be downloaded and processed "at once", i.e. this number of files is downloaded, read, masked, averaged and written to the database before loading new files. By doing so, at least some data will be available in the database in case that too many files cause a crash.

control

object returned by a former call to this function that contains the current state of the import process and takes care that the next block of required data is downloaded. When omitted, the function returns an object that can be used as a control object for a next call of this function. See example.

info

if TRUE (the default), a message is shown that describes how to use this function in a loop

urls

vector of URLs to Radolan files. By default, the URLs are determined within the function, considering the available measurements. However, the user may override this behaviour by giving the URLs here. Only used when control = NULL, otherwise the URLs are taken from the control object.

Value

vector of integer containing the IDs of the records inserted into the "rains" database table.

Examples

1
2
3
4
5
6
7
## Not run: 
control <- provide_rain_data_for_bathing_spot(user_id = 5, spot_id = 41)
while (control$remaining > 0) {
  control <- provide_rain_data_for_bathing_spot(control = control)
}

## End(Not run)

KWB-R/fhpredict documentation built on Nov. 1, 2020, 5:58 a.m.