get_weather: Download weather data from online database

View source: R/get_weather.R

get_weatherR Documentation

Download weather data from online database


This function retrieves either a list of nearby weather stations for a specified point location, or it downloads weather data for a specific weather station.


  time_interval = NA,
  database = "UCIPM",
  station_list = NULL,
  stations_to_choose_from = 25,
  end_at_present = TRUE



either a vector of geographic coordinates, or the 'chillRcode' of a weather station in the specified database. See details.


numeric vector with two elements, specifying the start and end date of the period of interest.


the database to be accessed. Must be "GSOD", "CIMIS" or "UCIPM". Since among these, "UCIPM" is the most comprehensive one for California, the initial area of interest, this is the default.


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 MB.


if the location is specified by geographic coordinates, this argument determines the number of nearby stations in the list that is returned.


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 time_interval[2] (if time_interval[2] is the current year).


weather databases, from which chillR can download data: NOAA NCDC Global Summary of the Day - "GSOD" (

California Irrigation Management Information System (CIMIS) - "CIMIS" (

University of California Integrated Pest Management (UCIPM) - "UCIPM" (

several formats are possible for specifying the location vector, which can consist of either two or three coordinates (it can include elevation). Possible formats include c(1,2,3), c(1,2), c(x=1,y=2,z=3), c(lat=2,long=1,elev=3). If elements of the vector are not names, they are interpreted as c(Longitude, Latitude, Elevation).

The 'chillRCode' is generated by this function, when it is run with geographic coordinates as location inputs. In the list of nearby stations that is returned then, the chillRCode is provided and can then be used as input for running the function in 'downloading' mode. For downloading the data, use the same call as before but replace the location argument with the chillRCode.


The output depends on how the location is provided. If it is a coordinate vector, the function returns a list of station_to_choose_from weather stations that are close to the specified location. This list also contains information about how far away these stations are (in km), how much the elevation difference is (if elevation is specified; in m) and how much overlap there is between the data contained in the database and the time period specified by time_interval.


Many databases have data quality flags, which may sometimes indicate that data aren't reliable. These are not considered by this function!

see the documentation of the handler functions (e.g. handle_ucipm) for details.


Eike Luedeling


The chillR package:

Luedeling E, Kunz A and Blanke M, 2013. Identification of chilling and heat requirements of cherry trees - a statistical approach. International Journal of Biometeorology 57,679-689.


#  time_interval=c(2002,2002))
#the line above takes longer to run than CRAN allows for examples. The line below therefore
#generates an abbreviated stat_list that allows running the code.

#   station_list = stat_list)

#  database="UCIPM")
  #after the first few lines here, the code should be "CEDARVIL.C"
#                "Chill_Portions",start_year=2005,end_year=2011,metriclabel="Chill Portions")

chillR documentation built on Nov. 28, 2023, 1:09 a.m.