weatherOz for DPIRD
Rodrigo Pires, Anna Hepworth, Rebecca O’Leary and Adam H. Sparks
Source:vignettes/weatherOz_for_DPIRD.Rmd
weatherOz_for_DPIRD.Rmd
Working With DPIRD Data
Three functions are provided to streamline fetching data from the DPIRD Weather 2.0 API endpoints.
-
get_dpird_extremes()
, which returns the recorded extreme values for the given station in the DPIRD weather station network.; -
get_dpird_minute()
, which returns weather data in minute increments for stations in the DPIRD weather station network with only the past two years being available; and -
get_dpird_summaries()
, which returns weather data in 15 and 30 minute, hourly, daily, monthly or yearly summary values for stations in the DPIRD weather station network.
A Note on API Keys
All examples in this vignette assume that you have stored your API key in your .Renviron file. See Chapter 8 in “What They Forgot to Teach You About R” by Bryan et al. for more on storing details in your .Renviron if you are unfamiliar.
Getting Extreme Weather Values
The get_dpird_extremes()
function fetches and returns
nicely formatted individual extreme weather summaries from the DPIRD
Weather 2.0 API. You must provide a station_code
and
API_key
, the other arguments, values
and
include_closed
are optional.
Available Values for Extreme Weather
- all (which will return all of the following values),
- erosionCondition,
- erosionConditionLast7Days,
- erosionConditionLast7DaysDays,
- erosionConditionLast7DaysMinutes,
- erosionConditionLast14Days,
- erosionConditionLast14DaysDays,
- erosionConditionLast14DaysMinutes,
- erosionConditionMonthToDate,
- erosionConditionMonthToDateDays,
- erosionConditionMonthToDateMinutes,
- erosionConditionMonthToDateStartTime,
- erosionConditionSince12AM,
- erosionConditionSince12AMMinutes,
- erosionConditionSince12AMStartTime,
- erosionConditionYearToDate,
- erosionConditionYearToDateDays,
- erosionConditionYearToDateMinutes,
- erosionConditionYearToDateStartTime,
- frostCondition,
- frostConditionLast7Days,
- frostConditionLast7DaysDays,
- frostConditionLast7DaysMinutes,
- frostConditionLast14Days,
- frostConditionLast14DaysDays,
- frostConditionLast14DaysMinutes,
- frostConditionMonthToDate,
- frostConditionMonthToDateDays,
- frostConditionMonthToDateMinutes,
- frostConditionMonthToDateStartTime,
- frostConditionSince9AM,
- frostConditionSince9AMMinutes,
- frostConditionSince9AMStartTime,
- frostConditionTo9AM,
- frostConditionTo9AMMinutes,
- frostConditionTo9AMStartTime,
- frostConditionYearToDate,
- frostConditionYearToDate,
- frostConditionYearToDateMinutes,
- frostConditionYearToDateStartTime,
- heatCondition,
- heatConditionLast7Days,
- heatConditionLast7DaysDays,
- heatConditionLast7DaysMinutes,
- heatConditionLast14Days,
- heatConditionLast14DaysDays,
- heatConditionLast14DaysMinutes,
- heatConditionMonthToDate,
- heatConditionMonthToDateDays,
- heatConditionMonthToDateMinutes,
- heatConditionMonthToDateStartTime,
- heatConditionSince12AM,
- heatConditionSince12AMMinutes,
- heatConditionSince12AMStartTime,
- heatConditionYearToDate,
- heatConditionYearToDateDays,
- heatConditionYearToDateMinutes, and
- heatConditionYearToDateStartTime
Example 1: Get All Extremes for Northam, WA
In the first example, we illustrate how to fetch all extreme values available for Northam.
library(weatherOz)
(extremes <- get_dpird_extremes(
station_code = "NO",
api_key = Sys.getenv("DPIRD_API_KEY")
))
Example 2: Get Selected Extremes for Northam, WA
Fetch only soil erosion extreme conditions for Northam, WA. The
documentation for get_dpird_extremes()
contains a full
listing of the values that are available to query from this API
endpoint.
library(weatherOz)
(
extremes <- get_dpird_extremes(
station_code = "NO",
values = "erosionCondition",
api_key = Sys.getenv("DPIRD_API_KEY")
)
)
Getting Minute Data
This function fetches nicely formatted minute weather station data
from the DPIRD Weather 2.0 API for a maximum 24-hour period. You must
provide a station_code
and API_key
, the other
arguments, start_date_time
, minutes
and
values
are optional.
Available Values for Minute Data
- all (which will return all of the following values),
- airTemperature,
- dateTime,
- dewPoint,
- rainfall,
- relativeHumidity,
- soilTemperature,
- solarIrradiance,
- wetBulb,
- wind,
- windAvgSpeed,
- windMaxSpeed, and
- windMinSpeed
Example 3: Get All Minute Data for the Past 24 Hours
library(weatherOz)
(
min_dat <- get_dpird_minute(
station_code = "NO",
api_key = Sys.getenv("DPIRD_API_KEY")
)
)
#> Key: <station_code>
#> station_code date_time air_temperature relative_humidity soil_temperature solar_irradiance rainfall
#> <fctr> <POSc> <num> <num> <num> <int> <int>
#> 1: NO 2024-04-18 13:05:00 30.7 23.5 35.1 761 0
#> 2: NO 2024-04-18 13:06:00 31.0 23.1 35.1 763 0
#> 3: NO 2024-04-18 13:07:00 30.9 23.1 35.2 761 0
#> 4: NO 2024-04-18 13:08:00 30.9 23.2 35.2 761 0
#> 5: NO 2024-04-18 13:09:00 31.1 22.9 35.2 761 0
#> ---
#> 1432: NO 2024-04-19 12:56:00 28.7 22.9 33.3 776 0
#> 1433: NO 2024-04-19 12:57:00 28.6 23.0 33.4 774 0
#> 1434: NO 2024-04-19 12:58:00 28.5 23.0 33.4 773 0
#> 1435: NO 2024-04-19 12:59:00 28.3 23.4 33.5 772 0
#> 1436: NO 2024-04-19 13:00:00 28.2 23.3 33.5 773 0
#> dew_point wet_bulb wind_height wind_avg_speed wind_avg_direction_compass_point wind_avg_direction_degrees
#> <num> <num> <int> <num> <char> <int>
#> 1: 7.5 17.5 3 4.18 NE 54
#> 2: 7.5 17.6 3 4.68 NE 34
#> 3: 7.4 17.5 3 3.17 NNE 13
#> 4: 7.5 17.5 3 5.69 NNE 26
#> 5: 7.5 17.6 3 6.19 E 79
#> ---
#> 1432: 5.5 16.0 3 3.17 ENE 77
#> 1433: 5.5 16.0 3 2.66 NE 52
#> 1434: 5.4 15.9 3 2.66 E 90
#> 1435: 5.4 15.9 3 3.17 ENE 73
#> 1436: 5.3 15.8 3 5.18 ENE 66
#> wind_min_speed wind_max_speed
#> <num> <num>
#> 1: 1.656 6.19
#> 2: 0.648 9.22
#> 3: 0.648 7.20
#> 4: 2.160 8.21
#> 5: 3.672 8.71
#> ---
#> 1432: 1.152 7.20
#> 1433: 1.152 5.69
#> 1434: 0.648 4.68
#> 1435: 1.152 5.69
#> 1436: 2.664 9.22
Example 4: Get Specific Time and Date Data for Specific Values
If you wish to supply a specific start date and time and values, you may do so as shown here.
library(weatherOz)
(
min_dat_t_rad_wind <- get_dpird_minute(
station_code = "NO",
start_date_time = "2023-02-01 13:00:00",
minutes = 1440,
values = c("airTemperature",
"solarIrradiance",
"wind"),
api_key = Sys.getenv("DPIRD_API_KEY")
)
)
#> Error in switch(values, all = c(weatherOz::dpird_minute_values, "dateTime"), : EXPR must be a length 1 vector
Getting Summary Data
The function, get_dpird_summary()
, fetches nicely
formatted minute weather station data from the DPIRD Weather 2.0 API for
a maximum 24-hour period. You must provide a station_code
and API_key
, the other arguments,
start_date_time
, minutes
and
values
are optional.
Available Values for Summary Data
- all (which will return all of the following values),
- airTemperature,
- airTemperatureAvg,
- airTemperatureMax,
- airTemperatureMaxTime,
- airTemperatureMin,
- airTemperatureMinTime,
- apparentAirTemperature,
- apparentAirTemperatureAvg,
- apparentAirTemperatureMax,
- apparentAirTemperatureMaxTime,
- apparentAirTemperatureMin,
- apparentAirTemperatureMinTime,
- barometricPressure,
- barometricPressureAvg,
- barometricPressureMax,
- barometricPressureMaxTime,
- barometricPressureMin,
- barometricPressureMinTime,
- battery,
- batteryMinVoltage,
- batteryMinVoltageDateTime,
- chillHours,
- deltaT,
- deltaTAvg,
- deltaTMax,
- deltaTMaxTime,
- deltaTMin,
- deltaTMinTime,
- dewPoint,
- dewPointAvg,
- dewPointMax,
- dewPointMaxTime,
- dewPointMin,
- dewPointMinTime,
- erosionCondition,
- erosionConditionMinutes,
- erosionConditionStartTime,
- errors,
- etoShortCrop,
- etoTallCrop,
- evapotranspiration,
- frostCondition,
- frostConditionMinutes,
- frostConditionStartTime,
- heatCondition,
- heatConditionMinutes,
- heatConditionStartTime,
- observations,
- observationsCount,
- observationsPercentage,
- panEvaporation,
- rainfall,
- relativeHumidity,
- relativeHumidityAvg,
- relativeHumidityMax,
- relativeHumidityMaxTime,
- relativeHumidityMin,
- relativeHumidityMinTime,
- richardsonUnits,
- soilTemperature,
- soilTemperatureAvg,
- soilTemperatureMax,
- soilTemperatureMaxTime,
- soilTemperatureMin,
- soilTemperatureMinTime,
- solarExposure,
- wetBulb,
- wetBulbAvg,
- wetBulbMax,
- wetBulbMaxTime,
- wetBulbMin,
- wetBulbMinTime,
- wind,
- windAvgSpeed, and
- windMaxSpeed
What You Get Back
This function returns a data.table
with
station_code
and the date interval queried together with
the requested weather variables in alphabetical order. Please note this
function converts date-time columns from Coordinated Universal Time
‘UTC’} to Australian Western Standard Time ‘AWST’. The first ten columns
will always be:
-
station_code
, -
station_name
, -
longitude
, -
latitude
, -
year
, -
month
, -
day
, -
hour
, -
minute
, and ifmonth
or finer is present, -
date
(a combination of year, month, day, hour, minute as appropriate)
Example 5: Get Annual Rainfall Since 2017
Use the default value for end date (current system date) to get annual rainfall since 2017 until current year for Capel.
library(weatherOz)
(
annual_rain <- get_dpird_summaries(
station_code = "CL001",
start_date = "20170101",
api_key = Sys.getenv("DPIRD_API_KEY"),
interval = "yearly",
values = "rainfall"
)
)
#> Key: <station_code>
#> station_code station_name longitude latitude year rainfall
#> <fctr> <char> <num> <num> <int> <num>
#> 1: CL001 Capel 115.6407 -33.60947 2017 711.4
#> 2: CL001 Capel 115.6407 -33.60947 2018 822.0
#> 3: CL001 Capel 115.6407 -33.60947 2019 660.6
#> 4: CL001 Capel 115.6407 -33.60947 2020 862.4
#> 5: CL001 Capel 115.6407 -33.60947 2021 928.0
#> 6: CL001 Capel 115.6407 -33.60947 2022 670.4
#> 7: CL001 Capel 115.6407 -33.60947 2023 570.0
#> 8: CL001 Capel 115.6407 -33.60947 2024 2.2
Example 6: Get Monthly Rainfall Since 2017
Use the default value for end date (current system date) to get monthly rainfall since 2017 until current year for Capel.
library(weatherOz)
(
monthly_rain <- get_dpird_summaries(
station_code = "CL001",
start_date = "20170101",
api_key = Sys.getenv("DPIRD_API_KEY"),
interval = "monthly",
values = "rainfall"
)
)
#> Key: <station_code>
#> station_code station_name longitude latitude year month date rainfall
#> <fctr> <char> <num> <num> <int> <int> <Date> <num>
#> 1: CL001 Capel 115.6407 -33.60947 2017 1 2017-01-01 0.0
#> 2: CL001 Capel 115.6407 -33.60947 2017 2 2017-02-01 0.0
#> 3: CL001 Capel 115.6407 -33.60947 2017 3 2017-03-01 59.6
#> 4: CL001 Capel 115.6407 -33.60947 2017 4 2017-04-01 0.0
#> 5: CL001 Capel 115.6407 -33.60947 2017 5 2017-05-01 84.0
#> 6: CL001 Capel 115.6407 -33.60947 2017 6 2017-06-01 57.8
#> 7: CL001 Capel 115.6407 -33.60947 2017 7 2017-07-01 194.4
#> 8: CL001 Capel 115.6407 -33.60947 2017 8 2017-08-01 175.8
#> 9: CL001 Capel 115.6407 -33.60947 2017 9 2017-09-01 49.8
#> 10: CL001 Capel 115.6407 -33.60947 2017 10 2017-10-01 34.0
#> 11: CL001 Capel 115.6407 -33.60947 2017 11 2017-11-01 14.2
#> 12: CL001 Capel 115.6407 -33.60947 2017 12 2017-12-01 41.8
#> 13: CL001 Capel 115.6407 -33.60947 2018 1 2018-01-01 14.4
#> 14: CL001 Capel 115.6407 -33.60947 2018 2 2018-02-01 0.2
#> 15: CL001 Capel 115.6407 -33.60947 2018 3 2018-03-01 15.4
#> 16: CL001 Capel 115.6407 -33.60947 2018 4 2018-04-01 42.8
#> 17: CL001 Capel 115.6407 -33.60947 2018 5 2018-05-01 115.2
#> 18: CL001 Capel 115.6407 -33.60947 2018 6 2018-06-01 168.8
#> 19: CL001 Capel 115.6407 -33.60947 2018 7 2018-07-01 214.6
#> 20: CL001 Capel 115.6407 -33.60947 2018 8 2018-08-01 156.8
#> 21: CL001 Capel 115.6407 -33.60947 2018 9 2018-09-01 29.6
#> 22: CL001 Capel 115.6407 -33.60947 2018 10 2018-10-01 45.8
#> 23: CL001 Capel 115.6407 -33.60947 2018 11 2018-11-01 11.2
#> 24: CL001 Capel 115.6407 -33.60947 2018 12 2018-12-01 7.2
#> 25: CL001 Capel 115.6407 -33.60947 2019 1 2019-01-01 6.0
#> 26: CL001 Capel 115.6407 -33.60947 2019 2 2019-02-01 0.0
#> 27: CL001 Capel 115.6407 -33.60947 2019 3 2019-03-01 29.4
#> 28: CL001 Capel 115.6407 -33.60947 2019 4 2019-04-01 33.0
#> 29: CL001 Capel 115.6407 -33.60947 2019 5 2019-05-01 27.0
#> 30: CL001 Capel 115.6407 -33.60947 2019 6 2019-06-01 239.6
#> 31: CL001 Capel 115.6407 -33.60947 2019 7 2019-07-01 85.4
#> 32: CL001 Capel 115.6407 -33.60947 2019 8 2019-08-01 117.8
#> 33: CL001 Capel 115.6407 -33.60947 2019 9 2019-09-01 45.8
#> 34: CL001 Capel 115.6407 -33.60947 2019 10 2019-10-01 67.0
#> 35: CL001 Capel 115.6407 -33.60947 2019 11 2019-11-01 7.8
#> 36: CL001 Capel 115.6407 -33.60947 2019 12 2019-12-01 1.8
#> 37: CL001 Capel 115.6407 -33.60947 2020 1 2020-01-01 2.0
#> 38: CL001 Capel 115.6407 -33.60947 2020 2 2020-02-01 31.8
#> 39: CL001 Capel 115.6407 -33.60947 2020 3 2020-03-01 40.8
#> 40: CL001 Capel 115.6407 -33.60947 2020 4 2020-04-01 41.6
#> 41: CL001 Capel 115.6407 -33.60947 2020 5 2020-05-01 156.2
#> 42: CL001 Capel 115.6407 -33.60947 2020 6 2020-06-01 132.4
#> 43: CL001 Capel 115.6407 -33.60947 2020 7 2020-07-01 125.8
#> 44: CL001 Capel 115.6407 -33.60947 2020 8 2020-08-01 96.0
#> 45: CL001 Capel 115.6407 -33.60947 2020 9 2020-09-01 110.0
#> 46: CL001 Capel 115.6407 -33.60947 2020 10 2020-10-01 32.6
#> 47: CL001 Capel 115.6407 -33.60947 2020 11 2020-11-01 88.0
#> 48: CL001 Capel 115.6407 -33.60947 2020 12 2020-12-01 5.2
#> 49: CL001 Capel 115.6407 -33.60947 2021 1 2021-01-01 0.0
#> 50: CL001 Capel 115.6407 -33.60947 2021 2 2021-02-01 76.2
#> 51: CL001 Capel 115.6407 -33.60947 2021 3 2021-03-01 27.4
#> 52: CL001 Capel 115.6407 -33.60947 2021 4 2021-04-01 92.0
#> 53: CL001 Capel 115.6407 -33.60947 2021 5 2021-05-01 160.6
#> 54: CL001 Capel 115.6407 -33.60947 2021 6 2021-06-01 81.2
#> 55: CL001 Capel 115.6407 -33.60947 2021 7 2021-07-01 187.6
#> 56: CL001 Capel 115.6407 -33.60947 2021 8 2021-08-01 90.4
#> 57: CL001 Capel 115.6407 -33.60947 2021 9 2021-09-01 93.4
#> 58: CL001 Capel 115.6407 -33.60947 2021 10 2021-10-01 109.4
#> 59: CL001 Capel 115.6407 -33.60947 2021 11 2021-11-01 5.4
#> 60: CL001 Capel 115.6407 -33.60947 2021 12 2021-12-01 4.4
#> 61: CL001 Capel 115.6407 -33.60947 2022 1 2022-01-01 0.0
#> 62: CL001 Capel 115.6407 -33.60947 2022 2 2022-02-01 4.4
#> 63: CL001 Capel 115.6407 -33.60947 2022 3 2022-03-01 4.6
#> 64: CL001 Capel 115.6407 -33.60947 2022 4 2022-04-01 44.0
#> 65: CL001 Capel 115.6407 -33.60947 2022 5 2022-05-01 105.6
#> 66: CL001 Capel 115.6407 -33.60947 2022 6 2022-06-01 103.8
#> 67: CL001 Capel 115.6407 -33.60947 2022 7 2022-07-01 169.0
#> 68: CL001 Capel 115.6407 -33.60947 2022 8 2022-08-01 121.4
#> 69: CL001 Capel 115.6407 -33.60947 2022 9 2022-09-01 69.4
#> 70: CL001 Capel 115.6407 -33.60947 2022 10 2022-10-01 29.0
#> 71: CL001 Capel 115.6407 -33.60947 2022 11 2022-11-01 18.0
#> 72: CL001 Capel 115.6407 -33.60947 2022 12 2022-12-01 1.2
#> 73: CL001 Capel 115.6407 -33.60947 2023 1 2023-01-01 0.8
#> 74: CL001 Capel 115.6407 -33.60947 2023 2 2023-02-01 0.0
#> 75: CL001 Capel 115.6407 -33.60947 2023 3 2023-03-01 27.8
#> 76: CL001 Capel 115.6407 -33.60947 2023 4 2023-04-01 81.2
#> 77: CL001 Capel 115.6407 -33.60947 2023 5 2023-05-01 31.8
#> 78: CL001 Capel 115.6407 -33.60947 2023 6 2023-06-01 130.0
#> 79: CL001 Capel 115.6407 -33.60947 2023 7 2023-07-01 123.2
#> 80: CL001 Capel 115.6407 -33.60947 2023 8 2023-08-01 74.8
#> 81: CL001 Capel 115.6407 -33.60947 2023 9 2023-09-01 80.2
#> 82: CL001 Capel 115.6407 -33.60947 2023 10 2023-10-01 17.2
#> 83: CL001 Capel 115.6407 -33.60947 2023 11 2023-11-01 2.4
#> 84: CL001 Capel 115.6407 -33.60947 2023 12 2023-12-01 0.6
#> 85: CL001 Capel 115.6407 -33.60947 2024 1 2024-01-01 1.4
#> 86: CL001 Capel 115.6407 -33.60947 2024 2 2024-02-01 0.6
#> 87: CL001 Capel 115.6407 -33.60947 2024 3 2024-03-01 0.2
#> 88: CL001 Capel 115.6407 -33.60947 2024 4 2024-04-01 0.0
#> station_code station_name longitude latitude year month date rainfall
Example 7: Get Daily Rainfall and Wind From Beginning of 2017 to End of 2018
Use the default value for end date (current system date) to get daily rainfall and wind records from 2017-01-01 to 2018-12-31 for Binnu. Note that the Binnu station has two wind heights, 3m and 10m.
library(weatherOz)
(
daily_wind_rain <- get_dpird_summaries(
station_code = "BI",
start_date = "20170101",
end_date = "2018-12-31",
api_key = Sys.getenv("DPIRD_API_KEY"),
interval = "daily",
values = c("rainfall",
"wind")
)
)
#> Key: <station_code>
#> station_code station_name longitude latitude year month day date rainfall wind_avg_speed wind_height
#> <fctr> <char> <num> <num> <int> <int> <int> <Date> <num> <num> <int>
#> 1: BI Binnu 114.6958 -28.051 2017 1 1 2017-01-01 0 4.28 3
#> 2: BI Binnu 114.6958 -28.051 2017 1 1 2017-01-01 0 6.85 10
#> 3: BI Binnu 114.6958 -28.051 2017 1 2 2017-01-02 0 4.53 3
#> 4: BI Binnu 114.6958 -28.051 2017 1 2 2017-01-02 0 7.39 10
#> 5: BI Binnu 114.6958 -28.051 2017 1 3 2017-01-03 0 4.74 3
#> ---
#> 1456: BI Binnu 114.6958 -28.051 2018 12 29 2018-12-29 0 35.63 10
#> 1457: BI Binnu 114.6958 -28.051 2018 12 30 2018-12-30 0 29.19 3
#> 1458: BI Binnu 114.6958 -28.051 2018 12 30 2018-12-30 0 36.70 10
#> 1459: BI Binnu 114.6958 -28.051 2018 12 31 2018-12-31 0 32.52 3
#> 1460: BI Binnu 114.6958 -28.051 2018 12 31 2018-12-31 0 41.51 10
#> wind_max_direction_compass_point wind_max_direction_degrees wind_max_speed wind_max_time
#> <char> <int> <num> <POSc>
#> 1: NNE 31 17.57 2018-07-17 11:51:00
#> 2: ESE 121 23.18 2017-07-30 11:38:00
#> 3: NE 41 21.78 2017-08-10 13:29:00
#> 4: N 1 19.55 2018-07-17 12:16:00
#> 5: WSW 247 18.40 2017-06-14 09:05:00
#> ---
#> 1456: SE 134 60.91 2017-02-09 15:56:00
#> 1457: ESE 105 62.03 2018-01-14 22:55:00
#> 1458: ESE 113 69.77 2018-01-14 22:45:00
#> 1459: SSE 163 58.64 2017-02-08 09:12:00
#> 1460: SSE 167 64.40 2017-02-08 04:48:00
Example 8: Get Hourly Rainfall and Wind From Beginning of 2022 to Current
Use the default value for end date (current system date) to get hourly rainfall and wind records from 2022-01-01 to Current Date for Binnu. Note that the Binnu station has two wind heights, 3m and 10m.
library(weatherOz)
(
hourly_wind_rain <- get_dpird_summaries(
station_code = "BI",
start_date = "20220101",
api_key = Sys.getenv("DPIRD_API_KEY"),
interval = "hourly",
values = c("rainfall",
"wind")
)
)
#> Key: <station_code>
#> station_code station_name longitude latitude year month day hour date rainfall
#> <fctr> <char> <num> <num> <int> <int> <int> <int> <POSc> <num>
#> 1: BI Binnu 114.6958 -28.051 2022 1 1 0 2022-01-01 00:00:00 0
#> 2: BI Binnu 114.6958 -28.051 2022 1 1 0 2022-01-01 00:00:00 0
#> 3: BI Binnu 114.6958 -28.051 2022 1 1 1 2022-01-01 01:00:00 0
#> 4: BI Binnu 114.6958 -28.051 2022 1 1 1 2022-01-01 01:00:00 0
#> 5: BI Binnu 114.6958 -28.051 2022 1 1 2 2022-01-01 02:00:00 0
#> ---
#> 40270: BI Binnu 114.6958 -28.051 2024 4 18 22 2024-04-18 22:00:00 0
#> 40271: BI Binnu 114.6958 -28.051 2024 4 18 23 2024-04-18 23:00:00 0
#> 40272: BI Binnu 114.6958 -28.051 2024 4 18 23 2024-04-18 23:00:00 0
#> 40273: BI Binnu 114.6958 -28.051 2024 4 19 0 2024-04-19 00:00:00 0
#> 40274: BI Binnu 114.6958 -28.051 2024 4 19 0 2024-04-19 00:00:00 0
#> wind_avg_direction_compass_point wind_avg_direction_degrees wind_avg_speed wind_height
#> <char> <int> <num> <int>
#> 1: NNE 18 0.00 3
#> 2: SSW 213 0.62 10
#> 3: NNE 33 0.00 3
#> 4: SSW 213 1.06 10
#> 5: ENE 58 0.00 3
#> ---
#> 40270: WNW 286 55.23 10
#> 40271: NW 313 43.20 3
#> 40272: NW 312 57.27 10
#> 40273: NW 317 44.32 3
#> 40274: NW 315 58.52 10
#> wind_max_direction_compass_point wind_max_direction_degrees wind_max_speed wind_max_time
#> <char> <int> <num> <POSc>
#> 1: N 1 0.00 2023-01-20 05:01:00
#> 2: NW 305 1.55 2023-04-08 00:58:00
#> 3: NNE 22 0.00 2022-07-23 01:01:00
#> 4: WSW 246 2.52 2023-04-08 02:00:00
#> 5: N 11 0.00 2023-02-04 22:01:00
#> ---
#> 40270: WNW 282 78.37 2023-09-13 14:25:00
#> 40271: NW 318 72.94 2023-09-13 12:39:00
#> 40272: NW 314 90.58 2023-09-13 12:24:00
#> 40273: NW 311 73.76 2023-09-13 11:40:00
#> 40274: NW 311 91.19 2023-09-13 11:34:00
Getting APSIM Ready Data
For work with APSIM, you can use get_dpird_apsim()
to
get an object in your R session that’s ready for saving using
[apsimx::write_apsim_met()] of DPIRD weather data. This function only
needs the station_code
, start_date
,
end_date
and your api_key
to return the
necessary values.
What You Get Back
An object of {apsimx} ‘met’ class, compatible with a
data.frame
, that has daily data that include year, day,
radiation, max temperature, min temperature, rainfall, relative
humidity, evaporation and windspeed.
Example 9: Get APSIM Formatted Data for Binnu From 2022-04-01 to 2022-11-01
library(weatherOz)
(
binnu <- get_dpird_apsim(
station_code = "BI",
start_date = "20220401",
end_date = "20221101",
api_key = Sys.getenv("DPIRD_API_KEY")
)
)
#>
#> Binnu.met
#> latitude = -28.051000 (DECIMAL DEGREES)
#> longitude = 114.695750 (DECIMAL DEGREES)
#> tav = 16.78 (oC) ! Average ambient temperature. Based on 2022-04-01 to 2022-11-01.
#> amp = 7.7 (oC) ! Amplitude in mean monthly temperature. Based on 2022-04-01 to 2022-11-01.
#> year day radn maxt mint rain evap rh windspeed
#> () () (MJ/m2/day) (oC) (oC) (mm) (%) (m/s) ()
#> year day radn maxt mint rain evap rh windspeed
#> 1 2022 91 8176.3 26.9 20.4 2.1 1.2 84.4 3.66
#> 2 2022 92 13439.8 27.6 20.4 3.2 2.0 85.4 3.82
#> 3 2022 93 14764.3 28.7 20.7 3.4 5.8 88.9 4.28
#> 4 2022 94 16305.3 28.2 19.9 4.4 2.2 81.5 4.43
#> 5 2022 95 23568.2 28.7 16.5 6.4 0.2 70.9 4.53
#> 6 2022 96 22831.7 32.3 15.6 7.2 0.0 57.7 4.70
Working With DPIRD Metadata
Three functions are provided to assist in fetching metadata about the stations.
-
find_nearby_stations()
, which returns adata.table
with the nearest weather stations to a given geographic point or known station either in the DPIRD or BOM (from SILO) networks. -
get_dpird_availability()
, which returns adata.table
with the availability for weather stations in the DPIRD network providing the up time and data availability for a given period of time. -
get_stations_metadata()
, which returns adata.table
with the latest and most up-to-date information available from the Weather 2.0 API on the stations’ geographic locations, hardware details, e.g., wind mast height, and recording capabilities.
Example 10: Finding Stations Nearby a Known Station
Query WA only stations and return DPIRD’s stations nearest to the Northam, WA station, “NO”, returning stations with 50 km of this station.
library(weatherOz)
(
wa_stn <- find_nearby_stations(
station_code = "NO",
distance_km = 50,
api_key = Sys.getenv("DPIRD_API_KEY"),
which_api = "dpird"
)
)
#> station_code station_name longitude latitude state elev_m
#> <fctr> <char> <num> <num> <char> <int>
#> 1: NO Northam 116.6942 -31.65161 WA 163
#> 2: MK Muresk 116.6913 -31.72772 WA 251
#> 3: YE001 York East 116.9211 -31.83588 WA 229
#> 4: BTSB DFES-B Talbot West 116.6898 -31.96060 WA 357
#> 5: ROGR Rolling Green 116.3184 -31.69527 WA 315
#> 6: BCAA DBCA-A Portable 116.2559 -31.84210 WA 267
#> owner distance_km
#> <char> <num>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD) 0.00
#> 2: WA Department of Primary Industries and Regional Development (DPIRD) 7.62
#> 3: WA Department of Primary Industries and Regional Development (DPIRD) 29.23
#> 4: WA Department of Fire and Emergency Services (DFES) 30.90
#> 5: WA Department of Biodiversity, Conservation and Attractions (DBCA) 37.83
#> 6: WA Department of Biodiversity, Conservation and Attractions (DBCA) 47.79
Example 11: Finding Stations Nearby a Given Longitude and Latitude
Using the longitude and latitude for Northam, WA, find all DPIRD stations within a 50km radius of this geographic point.
library(weatherOz)
(
wa_stn_lonlat <- find_nearby_stations(
longitude = 116.6620,
latitude = -31.6540,
distance_km = 50,
api_key = Sys.getenv("DPIRD_API_KEY"),
which_api = "dpird"
)
)
#> station_code station_name longitude latitude state elev_m
#> <fctr> <char> <num> <num> <char> <int>
#> 1: NO Northam 116.6942 -31.65161 WA 163
#> 2: MK Muresk 116.6913 -31.72772 WA 251
#> 3: BTSB DFES-B Talbot West 116.6898 -31.96060 WA 357
#> 4: YE001 York East 116.9211 -31.83588 WA 229
#> 5: ROGR Rolling Green 116.3184 -31.69527 WA 315
#> 6: BCAA DBCA-A Portable 116.2559 -31.84210 WA 267
#> owner distance_km
#> <char> <num>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD) 3.23
#> 2: WA Department of Primary Industries and Regional Development (DPIRD) 7.93
#> 3: WA Department of Fire and Emergency Services (DFES) 30.79
#> 4: WA Department of Primary Industries and Regional Development (DPIRD) 31.65
#> 5: WA Department of Biodiversity, Conservation and Attractions (DBCA) 34.61
#> 6: WA Department of Biodiversity, Conservation and Attractions (DBCA) 44.75
Example 12: Finding Stations in Both the DPIRD and SILO Data Sets
Query stations nearest DPIRD’s Northam, WA station, “NO” and return both DPIRD and SILO/BOM stations within 50 km of this station.
library(weatherOz)
(
wa_stn_all <- find_nearby_stations(
station_code = "NO",
distance_km = 50,
api_key = Sys.getenv("DPIRD_API_KEY"),
which_api = "all"
)
)
#> station_code station_name longitude latitude state elev_m
#> <fctr> <char> <num> <num> <char> <num>
#> 1: NO Northam 116.6942 -31.65161 WA 163
#> 2: 010111 Northam 116.6586 -31.65080 WA 170
#> 3: MK Muresk 116.6913 -31.72772 WA 251
#> 4: 010150 Grass Valley 116.7969 -31.63580 WA 200
#> 5: 010152 Muresk Institute 116.6833 -31.75000 WA 166
#> 6: 010115 Quellington 116.8647 -31.77140 WA 220
#> 7: 010125 Toodyay 116.4703 -31.55170 WA 140
#> 8: 010244 Bakers Hill 116.4561 -31.74690 WA 330
#> 9: 010311 York 116.7650 -31.89970 WA 179
#> 10: 010023 Warradong Farm 116.9411 -31.50030 WA 240
#> 11: YE001 York East 116.9211 -31.83588 WA 229
#> 12: 010091 Meckering 117.0081 -31.63220 WA 195
#> 13: BTSB DFES-B Talbot West 116.6898 -31.96060 WA 357
#> 14: ROGR Rolling Green 116.3184 -31.69527 WA 315
#> 15: 010138 Wooroloo 116.3413 -31.81500 WA 277
#> 16: 010058 Goomalling 116.8269 -31.29940 WA 239
#> 17: 010134 Wattening 116.5150 -31.31190 WA 240
#> 18: 010165 Green Hills 116.9839 -31.94080 WA 244
#> 19: 010163 Jaroma 117.1433 -31.77060 WA 265
#> 20: 010009 Bolgart 116.5092 -31.27440 WA 240
#> 21: 010160 Quella Park 117.1194 -31.45330 WA 265
#> 22: 009007 Chidlow 116.2658 -31.86220 WA 300
#> 23: 010120 Doodenanning 117.0986 -31.90920 WA 290
#> 24: BCAA DBCA-A Portable 116.2559 -31.84210 WA 267
#> 25: 009066 Gidgegannup 116.1976 -31.79060 WA 290
#> station_code station_name longitude latitude state elev_m
#> owner distance_km
#> <char> <num>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD) 0.000000
#> 2: BOM 3.369959
#> 3: WA Department of Primary Industries and Regional Development (DPIRD) 7.620000
#> 4: BOM 9.878912
#> 5: BOM 10.986728
#> 6: BOM 20.914807
#> 7: BOM 23.934879
#> 8: BOM 24.889495
#> 9: BOM 28.381350
#> 10: BOM 28.808439
#> 11: WA Department of Primary Industries and Regional Development (DPIRD) 29.230000
#> 12: BOM 29.790490
#> 13: WA Department of Fire and Emergency Services (DFES) 30.900000
#> 14: WA Department of Biodiversity, Conservation and Attractions (DBCA) 37.830000
#> 15: BOM 37.993263
#> 16: BOM 41.128932
#> 17: BOM 41.412805
#> 18: BOM 42.226585
#> 19: BOM 44.489821
#> 20: BOM 45.457855
#> 21: BOM 45.923973
#> 22: BOM 46.778842
#> 23: BOM 47.759247
#> 24: WA Department of Biodiversity, Conservation and Attractions (DBCA) 47.790000
#> 25: BOM 49.440793
#> owner distance_km
Example 13: Checking Station Availability for Current Year
Check the availability of the Westonia station since the start of the
current year using the default functionality with no
start_date
or end_date
.
library(weatherOz)
(WS001 <- get_dpird_availability(
station_code = "WS001",
api_key = Sys.getenv("DPIRD_API_KEY")
))
#> Key: <station_code>
#> station_code station_name to9_am since9_am since12_am current_hour last24_hours last7_days_since9_am
#> <fctr> <char> <int> <int> <int> <int> <int> <int>
#> 1: WS001 Westonia 100 100 100 100 100 100
#> last7_days_since12_am last14_days_since9_am last14_days_since12_am month_to_date_to9_am month_to_date_since12_am
#> <int> <int> <int> <int> <int>
#> 1: 100 100 100 100 100
#> year_to_date_to9_am year_to_date_since12_am
#> <int> <int>
#> 1: 100 100
Example 14: Checking Station Availability for a Set Time Period
Check the availability of the Binnu station for January of 2018. When
a custom start_date
is provided an end_date
must also be provided.
library(weatherOz)
(
BI_201801 <- get_dpird_availability(
station_code = "BI",
start_date = "2018-01-01",
end_date = "2018-01-31",
api_key = Sys.getenv("DPIRD_API_KEY")
)
)
#> Key: <station_code>
#> station_code station_name start_date end_date availability_since_9_am availability_since_12_am
#> <fctr> <char> <POSc> <POSc> <int> <int>
#> 1: BI Binnu 2018-01-01 2018-01-31 100 100
Getting Station Metadata for the DPIRD Network Stations
The get_stations_metadata()
function is shared with the
SILO functions as well, so this function will retrieve data from both
weather APIs. Shown here is how to use it for DPIRD data only and with
an example of DPIRD specific information, namely including closed
stations and rich metadata.
Example 15: Get DPIRD Station Metadata
The get_stations_metadata()
function allows you to get
details about the stations themselves for stations in the DPIRD and SILO
(BOM) networks in one function. Here we demonstrate how to get the
metadata for the DPIRD stations only.
library(weatherOz)
(metadata <- get_stations_metadata(which_api = "dpird",
api_key = Sys.getenv("DPIRD_API_KEY")))
#> station_code station_name start end latitude longitude state elev_m
#> <char> <char> <Date> <Date> <num> <num> <char> <int>
#> 1: AN001 Allanooka 2012-06-19 2024-04-19 -29.06361 114.9972 WA 131
#> 2: AM001 Amelup 2019-10-09 2024-04-19 -34.27083 118.2685 WA 200
#> 3: SH002 Babakin 2016-06-22 2024-04-19 -32.12548 118.0041 WA 313
#> 4: BA Badgingarra 2008-11-19 2024-04-19 -30.33805 115.5395 WA 284
#> 5: BP001 Balingup 2014-10-24 2024-04-19 -33.79620 116.0640 WA 227
#> ---
#> 226: YS Yilgarn 2008-11-01 2024-04-19 -31.91562 119.2561 WA 468
#> 227: YE001 York East 2013-11-08 2024-04-19 -31.83588 116.9211 WA 229
#> 228: YU001 Yuna 2012-06-21 2024-04-19 -28.33763 114.9898 WA 329
#> 229: YU002 Yuna NE 2016-03-24 2024-04-19 -28.20032 115.2616 WA 267
#> 230: YU003 Yuna North 2018-08-08 2024-04-19 -28.12086 114.9626 WA 264
#> source status wmo
#> <char> <char> <lgcl>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 2: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 3: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 4: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 5: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> ---
#> 226: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 227: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 228: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 229: WA Department of Primary Industries and Regional Development (DPIRD) open NA
#> 230: WA Department of Primary Industries and Regional Development (DPIRD) open NA
Example 16: Get Rich DPIRD Station Metadata and Include Closed Stations
You can fetch additional information about the DPIRD stations as well
as getting data for stations that are no longer open like so with the
rich
and include_closed
arguments set to
TRUE
.
library(weatherOz)
(metadata <- get_stations_metadata(which_api = "dpird",
include_closed = TRUE,
rich = TRUE,
api_key = Sys.getenv("DPIRD_API_KEY")))
#> station_code station_name start end latitude longitude state elev_m
#> <char> <char> <Date> <Date> <num> <num> <char> <int>
#> 1: AN001 Allanooka 2012-06-19 2024-04-19 -29.06361 114.9972 WA 131
#> 2: AM001 Amelup 2019-10-09 2024-04-19 -34.27083 118.2685 WA 200
#> 3: SH002 Babakin 2016-06-22 2024-04-19 -32.12548 118.0041 WA 313
#> 4: BA Badgingarra 2008-11-19 2024-04-19 -30.33805 115.5395 WA 284
#> 5: BP001 Balingup 2014-10-24 2024-04-19 -33.79620 116.0640 WA 227
#> ---
#> 234: YS Yilgarn 2008-11-01 2024-04-19 -31.91562 119.2561 WA 468
#> 235: YE001 York East 2013-11-08 2024-04-19 -31.83588 116.9211 WA 229
#> 236: YU001 Yuna 2012-06-21 2024-04-19 -28.33763 114.9898 WA 329
#> 237: YU002 Yuna NE 2016-03-24 2024-04-19 -28.20032 115.2616 WA 267
#> 238: YU003 Yuna North 2018-08-08 2024-04-19 -28.12086 114.9626 WA 264
#> source status wmo probe_height
#> <char> <char> <lgcl> <num>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 2: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 3: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 4: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 5: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> ---
#> 234: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 235: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 236: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 237: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> 238: WA Department of Primary Industries and Regional Development (DPIRD) open NA 1.25
#> rain_gauge_height wind_probe_heights air_temperature battery_voltage delta_t dew_point pan_evaporation
#> <num> <list> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
#> 1: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 2: 1.0 3 TRUE TRUE TRUE TRUE TRUE
#> 3: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 4: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 5: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> ---
#> 234: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 235: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 236: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 237: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> 238: 0.5 3 TRUE TRUE TRUE TRUE TRUE
#> relative_humidity barometric_pressure rainfall soil_temperature solar_irradiance wet_bulb wind1 wind2 wind3
#> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
#> 1: TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE FALSE
#> 2: TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE FALSE
#> 3: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> 4: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> 5: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> ---
#> 234: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> 235: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> 236: TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE FALSE
#> 237: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> 238: TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE
#> apparent_temperature eto_short eto_tall frost_condition heat_condition wind_erosion_condition richardson_unit
#> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
#> 1: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 2: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 3: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 4: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 5: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> ---
#> 234: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 235: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 236: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 237: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> 238: TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> chill_hour
#> <lgcl>
#> 1: TRUE
#> 2: TRUE
#> 3: TRUE
#> 4: TRUE
#> 5: TRUE
#> ---
#> 234: TRUE
#> 235: TRUE
#> 236: TRUE
#> 237: TRUE
#> 238: TRUE