handle_cdc_germany: Handle historic weather records from stations across Germany

View source: R/handle_cdc_germany.R

handle_cdc_germanyR Documentation

Handle historic weather records from stations across Germany

Description

This function access the Climate Data Center - CDC and allows to:

  • 1) obtain information of the weather stations from Germany.

  • 2) get weather data for one or more specific places of interest given the ID of the weather station.

Usage

handle_cdc_germany(
  action,
  variables,
  location = NA,
  begin = 19160101,
  end = chillR::Date2YEARMODA(Sys.Date()),
  number_of_stations = 25,
  add.DATE = FALSE,
  quiet = FALSE
)

Arguments

action

is a character string to decide on 2 modes of action for the function.

  • "list_stations" returns a dataframe with the information on close weather stations to the location defined by number_of_stations and location parameters.

  • "download_weather" retrieves the records for one or more weather stations defined in the location parameter.

variables

is a character vector representing the variables requested For now, the function can return the wind speed (mean - "Wind_speed" and maximum - "Wind_speed_max"); the atmospheric pressure ("ATM_pressure"); the rainfall ("Rainfall"); the precipitation as snow ("Snow"), the minimum temperature 5 cm above the ground ("Tmin_5cm"); the air temperature 2 m above ground (minimum - "Tmin", mean - "Tmean", and maximum - "Tmax"); the relative humidity ("RH"); and the vapor pressure deficit ("VPD").

location

accepts a numeric vector with two elements representing the longitude and latitude of a given place or a vector of character strings representing the ID of the weather stations of interest. If action = "list_stations", location requires the coordinates of the place. This vector can be named or not. Accepted names are: "y", "Y", "latitude", "lat", "Latitude", "Lat", "LATITUDE", "LAT" for latitude and "x", "X", "longitude", "long", "Longitude", "Long", "LONGITUDE", "LONG". If action = "download_weather", location accepts the ID of the station as character string.

begin

is a numeric parameter representing the start date for the period required. This must be specified in YEARMODA format.

end

is a numeric parameter representing the end date for the period required. This must be specified in YEARMODA format.

number_of_stations

is a numeric parameter defininf the numbers of stations to select from.

add.DATE

is a boolean parameter to be passed to make_all_day_table

quiet

is a boolean parameter to be passed to download.file

Details

If "list_stations" is used, the function returns a dataframe (9 columns x number_of_stations rows) containing information such as the name, latitude, longitude, begin, end and distance of the weather stations. If "download_weather" is chosen, it downloads the weather data from the CDC website. The output is a dataframe (in chillR format) for all stations selected in the location parameter.

Examples


handle_cdc_germany(action = "list_stations", variables = c("Tmin", "Tmax", "Tmean"),
                   location = c(latitude = 53.5373, longitude = 9.6397), begin = 20000101,
                   end = 20101231, number_of_stations = 25)


EduardoFernandezC/dormancyR documentation built on Aug. 24, 2022, 7:21 a.m.