handle_dwd | R Documentation |
This function accesses the Deutscher Wetterdienst database and allows to:
1) list a number of weather stations that are close to a specific position (geographic coordinates)
2) obtain weather data for one or more weather stations through the station ID
3) 'clean' and 'format' downloaded data, so the records can easily be used in other chillR functions
handle_dwd(
action,
location = NA,
time_interval = c(19160101, Date2YEARMODA(Sys.Date())),
station_list = NULL,
stations_to_choose_from = 25,
drop_most = TRUE,
end_at_present = TRUE,
add.DATE = FALSE,
quiet = FALSE,
add_station_name = FALSE
)
action |
is a character string to decide on 3 modes of action for the function.
|
location |
accepts a numeric vector with two or three elements representing the longitude,
latitude, and elevation of a given place or a vector of character strings representing the ID
of the weather stations of interest.
If |
time_interval |
numeric vector with two elements, specifying the start and end date
of the period of interest. Only required when running in |
station_list |
accepts a data frame if the list of weather stations has already been
downloaded. The list can be passed to the function through this argument. This can save a bit
of time, since it can take a bit of time to download the list, which can have several
|
stations_to_choose_from |
if the location is specified by geographic coordinates, this argument determines the number of nearby stations in the list that is returned. |
drop_most |
boolean variable indicating if most columns should be dropped from the
file if a list of data frames is provided to the |
end_at_present |
boolean variable indicating whether the interval of interest
should end on the present day, rather than extending until the end of the year specified
under |
add.DATE |
is a boolean parameter to be passed to |
quiet |
is a boolean parameter to be passed to
|
add_station_name |
is a boolean parameter to include the name of the respective weather station in the resulting data frame in case the function is used in the downloading or formatting mode. |
If action = 'list_stations'
, the function returns a data frame with
'stations_to_choose_from'
rows and 9 columns. This data frame contains information
about the weather stations (Latitude, Longitude, among others). If
action = 'download_weather'
, the function returns a list of length according to the
length of the location
parameter. Each list elements is a data frame
containing the data downloaded from the database. If the action
is provided
with the list generated by the function in the downloading mode, the function will
return a list of data frames structured according to the chillR format.
If drop_most
is set to TRUE
, the function will keep only the
most relevant variables for standard chillR analyses.
Many databases have data quality flags, which may sometimes indicate that data aren't reliable. These are not considered by this function!
Eduardo Fernandez and Eike Luedeling
Fernandez, E., Whitney, C., and Luedeling, E. 2020. The importance of chill model selection - A multi-site analysis. European Journal Of Agronomy 119: 126103
# The following lines may take longer than required to pass the
# CRAN checks. Please, un-comment them to run the example
# stations <- handle_dwd(action = "list_stations",
# location = c(latitude = 53.5373, longitude = 9.6397),
# time_interval = c(20000101, 20101231),
# stations_to_choose_from = 25)
# data <- handle_dwd(action = "download_weather",
# location = stations[1 : 3, "Station_ID"],
# time_interval = c(20000101, 20020601),
# stations_to_choose_from = 25,
# station_list = stations,
# drop_most = TRUE,
# add.DATE = FALSE,
# quiet = TRUE,
# add_station_name = FALSE)
# data_modified <- handle_dwd(data, add.DATE = TRUE, drop_most = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.