Skip to contents

Return a data frame containing SILO Australian weather data for the specified latitude/longitude, date range (from start_date to finish_date, inclusive) and the specified variables. By default, all available weather variables are returned if none are specified. If no finish date is provided, the date range is taken from the given start date up to today's date (i.e. so up to the most recently uploaded weather information on the SILO server, which is updated daily).

Usage

get_weather_data(
  latitude,
  longitude,
  start_date,
  finish_date = Sys.Date(),
  variables = weather_variables()$variable_name,
  pretty_names = TRUE
)

Arguments

latitude

The latitude (in decimal degrees North)

longitude

The longitude (in decimal degrees East)

start_date

A string or Date object for the starting date

finish_date

A string or Date object for the finish date (Default: today's date, so retrieves up to most recently updated weather data available)

variables

A vector containing the variable names (Default: retrieve all available weather variables)

pretty_names

Whether to format the columns with prettied variable names (Default: TRUE). Set this to FALSE to format the column names as syntactically valid variable names (at the cost of some readability)

Value

A data.frame containing the downloaded weather data

Examples

weather_data <- get_weather_data(-34.9, 138.6,
'2021-01-01', '2021-01-30', pretty_names = FALSE)
colnames(weather_data)
#>  [1] "Date"                                                            
#>  [2] "Latitude"                                                        
#>  [3] "Longitude"                                                       
#>  [4] "Elevation..m."                                                   
#>  [5] "Rainfall..mm."                                                   
#>  [6] "Minimum.Temperature..degC."                                      
#>  [7] "Maximum.Temperature..degC."                                      
#>  [8] "Relative.Humidity.at.Minimum.Temperature...."                    
#>  [9] "Relative.Humidity.at.Maximum.Temperature...."                    
#> [10] "Solar.Exposure..MJ.m2."                                          
#> [11] "Mean.Pressure.at.Sea.Level..hPa."                                
#> [12] "Vapour.Pressure..hPa."                                           
#> [13] "Vapour.Pressure.Deficit..hPa."                                   
#> [14] "Evaporation..mm."                                                
#> [15] "Morton.s.Shallow.Lake.Evaporation..mm."                          
#> [16] "FAO56.Short.Crop.Evapotranspiration..mm."                        
#> [17] "ASCE.Tall.Crop.Evapotranspiration..mm."                          
#> [18] "Morton.s.Areal.Actual.Evapotranspiration..mm."                   
#> [19] "Morton.s.Point.Potential.Evapotranspiration..mm."                
#> [20] "Morton.s.Wet.environment.Areal.Potential.Evapotranspiration..mm."
head(weather_data[,1:6])
#>         Date Latitude Longitude Elevation..m. Rainfall..mm.
#> 1 2021-01-01    -34.9     138.6          42.2             0
#> 2 2021-01-02    -34.9     138.6          42.2             0
#> 3 2021-01-03    -34.9     138.6          42.2             0
#> 4 2021-01-04    -34.9     138.6          42.2             0
#> 5 2021-01-05    -34.9     138.6          42.2             0
#> 6 2021-01-06    -34.9     138.6          42.2             0
#>   Minimum.Temperature..degC.
#> 1                       14.5
#> 2                       16.7
#> 3                       16.8
#> 4                       16.4
#> 5                       13.5
#> 6                       14.4

weather_data <- get_weather_data(
  -34.18, 139.98, '2020-01-01', '2020-03-31', c('rainfall', 'max_temp')
)
head(weather_data)
#>         Date Latitude Longitude Elevation (m) Rainfall (mm)
#> 1 2020-01-01   -34.18    139.98          41.0           0.0
#> 2 2020-01-02   -34.18    139.98          41.0           0.0
#> 3 2020-01-03   -34.18    139.98          41.0           0.0
#> 4 2020-01-04   -34.18    139.98          41.0           0.0
#> 5 2020-01-05   -34.18    139.98          41.0           9.2
#> 6 2020-01-06   -34.18    139.98          41.0           7.1
#>   Maximum Temperature (degC)
#> 1                       30.7
#> 2                       35.3
#> 3                       42.2
#> 4                       28.6
#> 5                       15.4
#> 6                       29.1