Skip to contents

Fetch nicely formatted minute weather station data from the DPIRD Weather 2.0 API for a maximum 24-hour period.

Usage

get_dpird_minute(
  station_code,
  start_date_time = lubridate::now() - lubridate::hours(24L),
  minutes = 1440L,
  values = "all",
  api_key = get_key(service = "DPIRD")
)

Arguments

station_code

A character string or factor from get_stations_metadata() of the BOM station code for the station of interest.

start_date_time

A character string representing the start date and time of the query in the format “yyyy-mm-dd-hh-mm” (ISO8601). Defaults to 24 hours before the current local system time, returning the most recent 24 hour observations rounded to the nearest minute. This function does its best to decipher many date and time formats but prefers ISO8601.

minutes

An integer value that provides the number of observations to be returned. Defaults to 1440 minutes for 24 hours of observations.

values

A vector of weather values to query from the API. See Available Values section for valid available codes. Defaults to all available values, all.

api_key

A character string containing your API key from DPIRD, https://www.agric.wa.gov.au/web-apis, for the DPIRD Weather 2.0 API. Defaults to automatically detecting your key from your local .Renviron, .Rprofile or similar. Alternatively, you may directly provide your key as a string here. If nothing is provided, you will be prompted on how to set up your R session so that it is auto-detected.

Value

a data.table::data.table() with station_code and the date interval queried together with the requested weather variables.

Note

Please note this function converts date-time columns from Coordinated Universal Time ‘UTC’ returned by the API to Australian Western Standard Time ‘AWST’.

Available Values

  • all (which will return all of the following values),

  • airTemperature,

  • dateTime,

  • dewPoint,

  • rainfall,

  • relativeHumidity,

  • soilTemperature,

  • solarIrradiance,

  • wetBulb,

  • wind,

  • windAvgSpeed,

  • windMaxSpeed, and

  • windMinSpeed

Author

Adam H. Sparks, adamhsparks@gmail.com

Examples

if (FALSE) { # \dontrun{

# Note that you need to supply your own API key

get_dpird_minute(
  station_code = "SP",
  start_date_time = "2023-02-01 13:00:00",
  minutes = 1440,
  values = c("airTemperature",
             "solarIrradiance",
             "wind"),
  api_key = "your_api_key"
)
} # }