weatherOz for DPIRD

Rodrigo Pires, Anna Hepworth, Rebecca O’Leary and Adam H. Sparks

About DPIRD Data

From the DPIRD Weather Website’s “About” Page.

The Department of Primary Industries and Regional Development’s (DPIRD) network of automatic weather stations and radars throughout the state provide timely, relevant and local weather data to assist growers and regional communities make more-informed decisions.

The weather station data includes air temperature, humidity, rainfall, wind speed and direction, with most stations also measuring incoming solar radiation to calculate evaporation. This website includes dashboards for each station to visualise this data.

Data from the DPIRD API are licenced under the Creative Commons Attribution 3.0 Licence (CC BY 3.0 AU).

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.

Working With DPIRD Data

Three functions are provided to streamline fetching data from the DPIRD Weather 2.0 API endpoints.

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

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"
))
#> Key: <station_code>
#>    station_code longitude  latitude frost_condition_since9_am_minutes
#>          <fctr>     <num>     <num>                             <int>
#> 1:           NO  116.6942 -31.65161                                 0
#>    frost_condition_since9_am_start_time frost_condition_to9_am_minutes
#>                                  <POSc>                          <int>
#> 1:                                 <NA>                              0
#>    frost_condition_to9_am_start_time frost_condition_last7_days_minutes
#>                               <POSc>                              <int>
#> 1:                              <NA>                                  0
#>    frost_condition_last7_days_days frost_condition_last14_days_minutes
#>                              <int>                               <int>
#> 1:                               0                                 493
#>    frost_condition_last14_days_days frost_condition_month_to_date_minutes
#>                               <int>                                 <int>
#> 1:                                2                                     0
#>    frost_condition_month_to_date_start_time frost_condition_month_to_date_days
#>                                      <POSc>                              <int>
#> 1:                                     <NA>                                  0
#>    frost_condition_year_to_date_minutes frost_condition_year_to_date_start_time
#>                                   <int>                                  <POSc>
#> 1:                                  543                     2024-05-23 05:59:00
#>    frost_condition_year_to_date_days heat_condition_since12_am_minutes
#>                                <int>                             <int>
#> 1:                                 4                                 0
#>    heat_condition_since12_am_start_time heat_condition_last7_days_minutes
#>                                  <POSc>                             <int>
#> 1:                                 <NA>                                 0
#>    heat_condition_last7_days_days heat_condition_last14_days_minutes
#>                             <int>                              <int>
#> 1:                              0                                  0
#>    heat_condition_last14_days_days heat_condition_month_to_date_minutes
#>                              <int>                                <int>
#> 1:                               0                                    0
#>    heat_condition_month_to_date_start_time heat_condition_month_to_date_days
#>                                     <POSc>                             <int>
#> 1:                                    <NA>                                 0
#>    heat_condition_year_to_date_minutes heat_condition_year_to_date_start_time
#>                                  <int>                                 <POSc>
#> 1:                               41050                    2024-01-01 12:06:00
#>    heat_condition_year_to_date_days erosion_condition_since12_am_minutes
#>                               <int>                                <int>
#> 1:                               92                                    0
#>    erosion_condition_since12_am_start_time erosion_condition_last7_days_minutes
#>                                     <POSc>                                <int>
#> 1:                                    <NA>                                    0
#>    erosion_condition_last7_days_days erosion_condition_last14_days_minutes
#>                                <int>                                 <int>
#> 1:                                 0                                     0
#>    erosion_condition_last14_days_days erosion_condition_month_to_date_minutes
#>                                 <int>                                   <int>
#> 1:                                  0                                       0
#>    erosion_condition_month_to_date_start_time
#>                                        <POSc>
#> 1:                                       <NA>
#>    erosion_condition_month_to_date_days erosion_condition_year_to_date_minutes
#>                                   <int>                                  <int>
#> 1:                                    0                                      9
#>    erosion_condition_year_to_date_start_time
#>                                       <POSc>
#> 1:                       2024-01-13 19:11:00
#>    erosion_condition_year_to_date_days
#>                                  <int>
#> 1:                                   2

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"
  )
)
#> Key: <station_code>
#>    station_code longitude  latitude erosion_condition_since12_am_minutes
#>          <fctr>     <num>     <num>                                <int>
#> 1:           NO  116.6942 -31.65161                                    0
#>    erosion_condition_since12_am_start_time erosion_condition_last7_days_minutes
#>                                     <POSc>                                <int>
#> 1:                                    <NA>                                    0
#>    erosion_condition_last7_days_days erosion_condition_last14_days_minutes
#>                                <int>                                 <int>
#> 1:                                 0                                     0
#>    erosion_condition_last14_days_days erosion_condition_month_to_date_minutes
#>                                 <int>                                   <int>
#> 1:                                  0                                       0
#>    erosion_condition_month_to_date_start_time
#>                                        <POSc>
#> 1:                                       <NA>
#>    erosion_condition_month_to_date_days erosion_condition_year_to_date_minutes
#>                                   <int>                                  <int>
#> 1:                                    0                                      9
#>    erosion_condition_year_to_date_start_time
#>                                       <POSc>
#> 1:                       2024-01-13 19:11:00
#>    erosion_condition_year_to_date_days
#>                                  <int>
#> 1:                                   2

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

Example 3: Get All Minute Data for the Past 24 Hours

library(weatherOz)

(
  min_dat <- get_dpird_minute(
    station_code = "NO"
  )
)
#> Key: <station_code>
#>       station_code           date_time air_temperature relative_humidity
#>             <fctr>              <POSc>           <num>             <num>
#>    1:           NO 2024-07-06 11:28:00            13.9              49.2
#>    2:           NO 2024-07-06 11:29:00            13.9              48.9
#>    3:           NO 2024-07-06 11:30:00            13.8              48.4
#>    4:           NO 2024-07-06 11:31:00            13.7              48.5
#>    5:           NO 2024-07-06 11:32:00            13.7              49.1
#>   ---                                                                   
#> 1429:           NO 2024-07-07 11:16:00            15.4              87.9
#> 1430:           NO 2024-07-07 11:17:00            15.4              88.0
#> 1431:           NO 2024-07-07 11:18:00            15.5              88.1
#> 1432:           NO 2024-07-07 11:19:00            15.5              87.8
#> 1433:           NO 2024-07-07 11:20:00            15.5              87.6
#>       soil_temperature solar_irradiance rainfall dew_point wet_bulb wind_height
#>                  <num>            <int>    <num>     <num>    <num>       <int>
#>    1:             10.6              294        0       3.4      9.3           3
#>    2:             10.6              250        0       3.3      9.2           3
#>    3:             10.6              225        0       3.1      9.1           3
#>    4:             10.7              330        0       3.0      9.0           3
#>    5:             10.7              341        0       3.2      9.1           3
#>   ---                                                                          
#> 1429:             13.0              193        0      13.4     14.4           3
#> 1430:             13.0              181        0      13.4     14.4           3
#> 1431:             13.0              214        0      13.5     14.5           3
#> 1432:             13.0              248        0      13.5     14.5           3
#> 1433:             13.0              260        0      13.5     14.4           3
#>       wind_avg_speed wind_avg_direction_compass_point
#>                <num>                           <char>
#>    1:           6.19                                N
#>    2:           5.18                              NNE
#>    3:           5.69                              NNE
#>    4:           7.70                               NE
#>    5:           7.20                              NNE
#>   ---                                                
#> 1429:          10.22                              NNW
#> 1430:          10.73                              NNW
#> 1431:           8.71                              NNW
#> 1432:          10.22                              NNW
#> 1433:           8.71                                N
#>       wind_avg_direction_degrees wind_min_speed wind_max_speed
#>                            <int>          <num>          <num>
#>    1:                         11          3.168           8.21
#>    2:                         31          2.664           9.22
#>    3:                         27          2.664          10.73
#>    4:                         34          5.184          11.74
#>    5:                         18          5.184          10.73
#>   ---                                                         
#> 1429:                        340          8.712          12.20
#> 1430:                        330          7.200          13.72
#> 1431:                        343          5.688          12.71
#> 1432:                        344          7.704          12.20
#> 1433:                        350          7.704          10.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")
  )
)
#> Key: <station_code>
#>       station_code           date_time air_temperature solar_irradiance
#>             <fctr>              <POSc>           <num>            <int>
#>    1:           NO 2023-02-01 13:00:00            29.7             1087
#>    2:           NO 2023-02-01 13:00:50            29.4             1086
#>    3:           NO 2023-02-01 13:01:40            29.5             1084
#>    4:           NO 2023-02-01 13:02:30            29.5             1084
#>    5:           NO 2023-02-01 13:03:20            29.6             1084
#>   ---                                                                  
#> 1436:           NO 2023-02-02 12:55:00            30.2             1105
#> 1437:           NO 2023-02-02 12:55:50            30.1             1104
#> 1438:           NO 2023-02-02 12:56:40            30.0             1102
#> 1439:           NO 2023-02-02 12:57:30            29.9             1102
#> 1440:           NO 2023-02-02 12:58:20            30.1             1104
#>       wind_height wind_avg_speed wind_avg_direction_compass_point
#>             <int>          <num>                           <char>
#>    1:           3          11.66                               SE
#>    2:           3          10.80                               SE
#>    3:           3          11.81                              SSE
#>    4:           3          12.71                               SE
#>    5:           3          12.96                               SE
#>   ---                                                            
#> 1436:           3           9.54                              ESE
#> 1437:           3           9.90                              ESE
#> 1438:           3          13.03                              ESE
#> 1439:           3          10.91                                E
#> 1440:           3          10.40                                E
#>       wind_avg_direction_degrees wind_min_speed wind_max_speed
#>                            <int>          <num>          <num>
#>    1:                        139          4.176          26.82
#>    2:                        136          4.176          19.26
#>    3:                        156          6.696          19.26
#>    4:                        133          6.696          26.82
#>    5:                        139          6.696          19.26
#>   ---                                                         
#> 1436:                        112          4.176          16.74
#> 1437:                        120          4.176          19.26
#> 1438:                        121          4.176          24.30
#> 1439:                         93          6.696          21.78
#> 1440:                         97          4.176          16.74

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

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:

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",
    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.6376 -33.61576  2017    711.4
#> 2:        CL001        Capel  115.6376 -33.61576  2018    822.0
#> 3:        CL001        Capel  115.6376 -33.61576  2019    660.6
#> 4:        CL001        Capel  115.6376 -33.61576  2020    862.4
#> 5:        CL001        Capel  115.6376 -33.61576  2021    928.0
#> 6:        CL001        Capel  115.6376 -33.61576  2022    670.4
#> 7:        CL001        Capel  115.6376 -33.61576  2023    570.0
#> 8:        CL001        Capel  115.6376 -33.61576  2024    281.8

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",
    interval = "monthly",
    values = "rainfall"
  )
)
#> Key: <station_code>
#>     station_code station_name longitude  latitude  year month       date
#>           <fctr>       <char>     <num>     <num> <int> <int>     <Date>
#>  1:        CL001        Capel  115.6376 -33.61576  2017     1 2017-01-01
#>  2:        CL001        Capel  115.6376 -33.61576  2017     2 2017-02-01
#>  3:        CL001        Capel  115.6376 -33.61576  2017     3 2017-03-01
#>  4:        CL001        Capel  115.6376 -33.61576  2017     4 2017-04-01
#>  5:        CL001        Capel  115.6376 -33.61576  2017     5 2017-05-01
#>  6:        CL001        Capel  115.6376 -33.61576  2017     6 2017-06-01
#>  7:        CL001        Capel  115.6376 -33.61576  2017     7 2017-07-01
#>  8:        CL001        Capel  115.6376 -33.61576  2017     8 2017-08-01
#>  9:        CL001        Capel  115.6376 -33.61576  2017     9 2017-09-01
#> 10:        CL001        Capel  115.6376 -33.61576  2017    10 2017-10-01
#> 11:        CL001        Capel  115.6376 -33.61576  2017    11 2017-11-01
#> 12:        CL001        Capel  115.6376 -33.61576  2017    12 2017-12-01
#> 13:        CL001        Capel  115.6376 -33.61576  2018     1 2018-01-01
#> 14:        CL001        Capel  115.6376 -33.61576  2018     2 2018-02-01
#> 15:        CL001        Capel  115.6376 -33.61576  2018     3 2018-03-01
#> 16:        CL001        Capel  115.6376 -33.61576  2018     4 2018-04-01
#> 17:        CL001        Capel  115.6376 -33.61576  2018     5 2018-05-01
#> 18:        CL001        Capel  115.6376 -33.61576  2018     6 2018-06-01
#> 19:        CL001        Capel  115.6376 -33.61576  2018     7 2018-07-01
#> 20:        CL001        Capel  115.6376 -33.61576  2018     8 2018-08-01
#> 21:        CL001        Capel  115.6376 -33.61576  2018     9 2018-09-01
#> 22:        CL001        Capel  115.6376 -33.61576  2018    10 2018-10-01
#> 23:        CL001        Capel  115.6376 -33.61576  2018    11 2018-11-01
#> 24:        CL001        Capel  115.6376 -33.61576  2018    12 2018-12-01
#> 25:        CL001        Capel  115.6376 -33.61576  2019     1 2019-01-01
#> 26:        CL001        Capel  115.6376 -33.61576  2019     2 2019-02-01
#> 27:        CL001        Capel  115.6376 -33.61576  2019     3 2019-03-01
#> 28:        CL001        Capel  115.6376 -33.61576  2019     4 2019-04-01
#> 29:        CL001        Capel  115.6376 -33.61576  2019     5 2019-05-01
#> 30:        CL001        Capel  115.6376 -33.61576  2019     6 2019-06-01
#> 31:        CL001        Capel  115.6376 -33.61576  2019     7 2019-07-01
#> 32:        CL001        Capel  115.6376 -33.61576  2019     8 2019-08-01
#> 33:        CL001        Capel  115.6376 -33.61576  2019     9 2019-09-01
#> 34:        CL001        Capel  115.6376 -33.61576  2019    10 2019-10-01
#> 35:        CL001        Capel  115.6376 -33.61576  2019    11 2019-11-01
#> 36:        CL001        Capel  115.6376 -33.61576  2019    12 2019-12-01
#> 37:        CL001        Capel  115.6376 -33.61576  2020     1 2020-01-01
#> 38:        CL001        Capel  115.6376 -33.61576  2020     2 2020-02-01
#> 39:        CL001        Capel  115.6376 -33.61576  2020     3 2020-03-01
#> 40:        CL001        Capel  115.6376 -33.61576  2020     4 2020-04-01
#> 41:        CL001        Capel  115.6376 -33.61576  2020     5 2020-05-01
#> 42:        CL001        Capel  115.6376 -33.61576  2020     6 2020-06-01
#> 43:        CL001        Capel  115.6376 -33.61576  2020     7 2020-07-01
#> 44:        CL001        Capel  115.6376 -33.61576  2020     8 2020-08-01
#> 45:        CL001        Capel  115.6376 -33.61576  2020     9 2020-09-01
#> 46:        CL001        Capel  115.6376 -33.61576  2020    10 2020-10-01
#> 47:        CL001        Capel  115.6376 -33.61576  2020    11 2020-11-01
#> 48:        CL001        Capel  115.6376 -33.61576  2020    12 2020-12-01
#> 49:        CL001        Capel  115.6376 -33.61576  2021     1 2021-01-01
#> 50:        CL001        Capel  115.6376 -33.61576  2021     2 2021-02-01
#> 51:        CL001        Capel  115.6376 -33.61576  2021     3 2021-03-01
#> 52:        CL001        Capel  115.6376 -33.61576  2021     4 2021-04-01
#> 53:        CL001        Capel  115.6376 -33.61576  2021     5 2021-05-01
#> 54:        CL001        Capel  115.6376 -33.61576  2021     6 2021-06-01
#> 55:        CL001        Capel  115.6376 -33.61576  2021     7 2021-07-01
#> 56:        CL001        Capel  115.6376 -33.61576  2021     8 2021-08-01
#> 57:        CL001        Capel  115.6376 -33.61576  2021     9 2021-09-01
#> 58:        CL001        Capel  115.6376 -33.61576  2021    10 2021-10-01
#> 59:        CL001        Capel  115.6376 -33.61576  2021    11 2021-11-01
#> 60:        CL001        Capel  115.6376 -33.61576  2021    12 2021-12-01
#> 61:        CL001        Capel  115.6376 -33.61576  2022     1 2022-01-01
#> 62:        CL001        Capel  115.6376 -33.61576  2022     2 2022-02-01
#> 63:        CL001        Capel  115.6376 -33.61576  2022     3 2022-03-01
#> 64:        CL001        Capel  115.6376 -33.61576  2022     4 2022-04-01
#> 65:        CL001        Capel  115.6376 -33.61576  2022     5 2022-05-01
#> 66:        CL001        Capel  115.6376 -33.61576  2022     6 2022-06-01
#> 67:        CL001        Capel  115.6376 -33.61576  2022     7 2022-07-01
#> 68:        CL001        Capel  115.6376 -33.61576  2022     8 2022-08-01
#> 69:        CL001        Capel  115.6376 -33.61576  2022     9 2022-09-01
#> 70:        CL001        Capel  115.6376 -33.61576  2022    10 2022-10-01
#> 71:        CL001        Capel  115.6376 -33.61576  2022    11 2022-11-01
#> 72:        CL001        Capel  115.6376 -33.61576  2022    12 2022-12-01
#> 73:        CL001        Capel  115.6376 -33.61576  2023     1 2023-01-01
#> 74:        CL001        Capel  115.6376 -33.61576  2023     2 2023-02-01
#> 75:        CL001        Capel  115.6376 -33.61576  2023     3 2023-03-01
#> 76:        CL001        Capel  115.6376 -33.61576  2023     4 2023-04-01
#> 77:        CL001        Capel  115.6376 -33.61576  2023     5 2023-05-01
#> 78:        CL001        Capel  115.6376 -33.61576  2023     6 2023-06-01
#> 79:        CL001        Capel  115.6376 -33.61576  2023     7 2023-07-01
#> 80:        CL001        Capel  115.6376 -33.61576  2023     8 2023-08-01
#> 81:        CL001        Capel  115.6376 -33.61576  2023     9 2023-09-01
#> 82:        CL001        Capel  115.6376 -33.61576  2023    10 2023-10-01
#> 83:        CL001        Capel  115.6376 -33.61576  2023    11 2023-11-01
#> 84:        CL001        Capel  115.6376 -33.61576  2023    12 2023-12-01
#> 85:        CL001        Capel  115.6376 -33.61576  2024     1 2024-01-01
#> 86:        CL001        Capel  115.6376 -33.61576  2024     2 2024-02-01
#> 87:        CL001        Capel  115.6376 -33.61576  2024     3 2024-03-01
#> 88:        CL001        Capel  115.6376 -33.61576  2024     4 2024-04-01
#> 89:        CL001        Capel  115.6376 -33.61576  2024     5 2024-05-01
#> 90:        CL001        Capel  115.6376 -33.61576  2024     6 2024-06-01
#> 91:        CL001        Capel  115.6376 -33.61576  2024     7 2024-07-01
#>     station_code station_name longitude  latitude  year month       date
#>     rainfall
#>        <num>
#>  1:      0.0
#>  2:      0.0
#>  3:     59.6
#>  4:      0.0
#>  5:     84.0
#>  6:     57.8
#>  7:    194.4
#>  8:    175.8
#>  9:     49.8
#> 10:     34.0
#> 11:     14.2
#> 12:     41.8
#> 13:     14.4
#> 14:      0.2
#> 15:     15.4
#> 16:     42.8
#> 17:    115.2
#> 18:    168.8
#> 19:    214.6
#> 20:    156.8
#> 21:     29.6
#> 22:     45.8
#> 23:     11.2
#> 24:      7.2
#> 25:      6.0
#> 26:      0.0
#> 27:     29.4
#> 28:     33.0
#> 29:     27.0
#> 30:    239.6
#> 31:     85.4
#> 32:    117.8
#> 33:     45.8
#> 34:     67.0
#> 35:      7.8
#> 36:      1.8
#> 37:      2.0
#> 38:     31.8
#> 39:     40.8
#> 40:     41.6
#> 41:    156.2
#> 42:    132.4
#> 43:    125.8
#> 44:     96.0
#> 45:    110.0
#> 46:     32.6
#> 47:     88.0
#> 48:      5.2
#> 49:      0.0
#> 50:     76.2
#> 51:     27.4
#> 52:     92.0
#> 53:    160.6
#> 54:     81.2
#> 55:    187.6
#> 56:     90.4
#> 57:     93.4
#> 58:    109.4
#> 59:      5.4
#> 60:      4.4
#> 61:      0.0
#> 62:      4.4
#> 63:      4.6
#> 64:     44.0
#> 65:    105.6
#> 66:    103.8
#> 67:    169.0
#> 68:    121.4
#> 69:     69.4
#> 70:     29.0
#> 71:     18.0
#> 72:      1.2
#> 73:      0.8
#> 74:      0.0
#> 75:     27.8
#> 76:     81.2
#> 77:     31.8
#> 78:    130.0
#> 79:    123.2
#> 80:     74.8
#> 81:     80.2
#> 82:     17.2
#> 83:      2.4
#> 84:      0.6
#> 85:      1.4
#> 86:      0.6
#> 87:      0.2
#> 88:      0.0
#> 89:     60.6
#> 90:    202.2
#> 91:     16.8
#>     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",
    interval = "daily",
    values = c("rainfall",
               "wind")
  )
)
#> Key: <station_code>
#>       station_code station_name longitude latitude  year month   day       date
#>             <fctr>       <char>     <num>    <num> <int> <int> <int>     <Date>
#>    1:           BI        Binnu  114.6958  -28.051  2017     1     1 2017-01-01
#>    2:           BI        Binnu  114.6958  -28.051  2017     1     1 2017-01-01
#>    3:           BI        Binnu  114.6958  -28.051  2017     1     2 2017-01-02
#>    4:           BI        Binnu  114.6958  -28.051  2017     1     2 2017-01-02
#>    5:           BI        Binnu  114.6958  -28.051  2017     1     3 2017-01-03
#>   ---                                                                          
#> 1456:           BI        Binnu  114.6958  -28.051  2018    12    29 2018-12-29
#> 1457:           BI        Binnu  114.6958  -28.051  2018    12    30 2018-12-30
#> 1458:           BI        Binnu  114.6958  -28.051  2018    12    30 2018-12-30
#> 1459:           BI        Binnu  114.6958  -28.051  2018    12    31 2018-12-31
#> 1460:           BI        Binnu  114.6958  -28.051  2018    12    31 2018-12-31
#>       rainfall wind_avg_speed wind_height wind_max_direction_compass_point
#>          <num>          <num>       <int>                           <char>
#>    1:        0           4.28           3                              NNE
#>    2:        0           6.85          10                              ESE
#>    3:        0           4.53           3                               NE
#>    4:        0           7.39          10                                N
#>    5:        0           4.74           3                              WSW
#>   ---                                                                     
#> 1456:        0          35.63          10                               SE
#> 1457:        0          29.19           3                              ESE
#> 1458:        0          36.70          10                              ESE
#> 1459:        0          32.52           3                              SSE
#> 1460:        0          41.51          10                              SSE
#>       wind_max_direction_degrees wind_max_speed       wind_max_time
#>                            <int>          <num>              <POSc>
#>    1:                         31          17.57 2018-07-17 11:51:00
#>    2:                        121          23.18 2017-07-30 11:38:00
#>    3:                         41          21.78 2017-08-10 13:29:00
#>    4:                          1          19.55 2018-07-17 12:16:00
#>    5:                        247          18.40 2017-06-14 09:05:00
#>   ---                                                              
#> 1456:                        134          60.91 2017-02-09 15:56:00
#> 1457:                        105          62.03 2018-01-14 22:55:00
#> 1458:                        113          69.77 2018-01-14 22:45:00
#> 1459:                        163          58.64 2017-02-08 09:12:00
#> 1460:                        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",
    interval = "hourly",
    values = c("rainfall",
               "wind")
  )
)
#> Key: <station_code>
#>        station_code station_name longitude latitude  year month   day  hour
#>              <fctr>       <char>     <num>    <num> <int> <int> <int> <int>
#>     1:           BI        Binnu  114.6958  -28.051  2022     1     1     0
#>     2:           BI        Binnu  114.6958  -28.051  2022     1     1     0
#>     3:           BI        Binnu  114.6958  -28.051  2022     1     1     1
#>     4:           BI        Binnu  114.6958  -28.051  2022     1     1     1
#>     5:           BI        Binnu  114.6958  -28.051  2022     1     1     2
#>    ---                                                                     
#> 44062:           BI        Binnu  114.6958  -28.051  2024     7     6    22
#> 44063:           BI        Binnu  114.6958  -28.051  2024     7     6    23
#> 44064:           BI        Binnu  114.6958  -28.051  2024     7     6    23
#> 44065:           BI        Binnu  114.6958  -28.051  2024     7     7     0
#> 44066:           BI        Binnu  114.6958  -28.051  2024     7     7     0
#>                       date rainfall wind_avg_direction_compass_point
#>                     <POSc>    <num>                           <char>
#>     1: 2022-01-01 00:00:00      0.0                              NNE
#>     2: 2022-01-01 00:00:00      0.0                             <NA>
#>     3: 2022-01-01 01:00:00      0.0                              NNE
#>     4: 2022-01-01 01:00:00      0.0                             <NA>
#>     5: 2022-01-01 02:00:00      0.0                              ENE
#>    ---                                                              
#> 44062: 2024-07-06 22:00:00      1.4                              WNW
#> 44063: 2024-07-06 23:00:00      1.0                               NW
#> 44064: 2024-07-06 23:00:00      1.0                               NW
#> 44065: 2024-07-07 00:00:00      1.4                               NW
#> 44066: 2024-07-07 00:00:00      1.4                               NW
#>        wind_avg_direction_degrees wind_avg_speed wind_height
#>                             <int>          <num>       <int>
#>     1:                         18           0.00           3
#>     2:                         NA             NA          10
#>     3:                         33           0.00           3
#>     4:                         NA             NA          10
#>     5:                         58           0.00           3
#>    ---                                                      
#> 44062:                        286          55.23          10
#> 44063:                        313          43.20           3
#> 44064:                        312          57.27          10
#> 44065:                        317          44.32           3
#> 44066:                        315          58.52          10
#>        wind_max_direction_compass_point wind_max_direction_degrees
#>                                  <char>                      <int>
#>     1:                                N                          1
#>     2:                             <NA>                         NA
#>     3:                              NNE                         22
#>     4:                             <NA>                         NA
#>     5:                                N                         11
#>    ---                                                            
#> 44062:                              WNW                        282
#> 44063:                               NW                        318
#> 44064:                               NW                        314
#> 44065:                               NW                        311
#> 44066:                               NW                        311
#>        wind_max_speed       wind_max_time
#>                 <num>              <POSc>
#>     1:           0.00 2023-01-20 05:01:00
#>     2:             NA                <NA>
#>     3:           0.00 2022-07-23 01:01:00
#>     4:             NA                <NA>
#>     5:           0.00 2023-02-04 22:01:00
#>    ---                                   
#> 44062:          78.37 2023-09-13 14:25:00
#> 44063:          72.94 2023-09-13 12:39:00
#> 44064:          90.58 2023-09-13 12:24:00
#> 44065:          73.76 2023-09-13 11:40:00
#> 44066:          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 of DPIRD weather data in your R session that’s ready for saving using write_apsim_met(), which is re-exported from the CRAN package [apsimx] for your convenience. This function only needs the station_code, start_date, end_date and your api_key values 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 = "20220101",
    end_date = "20221231"
  )
)
#> weather.met.met 
#> site = Binnu 
#> latitude = -28.051 
#> longitude = 114.69575 
#> tav = 20.5987671232877 (oC) ! calculated annual average ambient temperature 2024-07-07 11:28:59.118214 
#> amp = 15.3 !calculated with the apsimx R package: 2024-07-07 11:28:59.123978 
#> year day radn maxt mint rain evap rh windspeed 
#> () () (MJ/m2/day) (oC) (oC) (mm) (mm) (%) (m/s) 
#>   year day    radn maxt mint rain evap   rh windspeed
#> 1 2022   1 33137.3 35.3 18.5 10.6    0 63.9      3.66
#> 2 2022   2 33419.1 38.3 15.2 11.1    0 54.6      3.82
#> 3 2022   3 33467.9 34.8 17.1 11.0    0 65.6      4.28
#> 4 2022   4 32784.2 39.9 17.6 11.2    0 64.2      4.43
#> 5 2022   5 32981.1 45.7 19.1 14.4    0 37.1      4.53
#> 6 2022   6 33182.6 39.1 18.3 11.3    0 60.5      4.70
#> Warning in check_apsim_met(x): Radiation is greater than 40 (MJ/m2/day)
#> weather.met.met 
#> site = Binnu 
#> latitude = -28.051 
#> longitude = 114.69575 
#> tav = 20.5987671232877 (oC) ! calculated annual average ambient temperature 2024-07-07 11:28:59.118214 
#> amp = 15.3 !calculated with the apsimx R package: 2024-07-07 11:28:59.123978 
#> year day radn maxt mint rain evap rh windspeed 
#> () () (MJ/m2/day) (oC) (oC) (mm) (mm) (%) (m/s) 
#>   year day    radn maxt mint rain evap   rh windspeed
#> 1 2022   1 33137.3 35.3 18.5 10.6    0 63.9      3.66
#> 2 2022   2 33419.1 38.3 15.2 11.1    0 54.6      3.82
#> 3 2022   3 33467.9 34.8 17.1 11.0    0 65.6      4.28
#> 4 2022   4 32784.2 39.9 17.6 11.2    0 64.2      4.43
#> 5 2022   5 32981.1 45.7 19.1 14.4    0 37.1      4.53
#> 6 2022   6 33182.6 39.1 18.3 11.3    0 60.5      4.70

Working With DPIRD Metadata

Three functions are provided to assist in fetching metadata about the stations.

Finding Nearby Stations

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,
    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.2560 -31.84210     WA    268
#>                                                                   owner
#>                                                                  <char>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD)
#> 2: WA Department of Primary Industries and Regional Development (DPIRD)
#> 3: WA Department of Primary Industries and Regional Development (DPIRD)
#> 4:                  WA Department of Fire and Emergency Services (DFES)
#> 5:   WA Department of Biodiversity, Conservation and Attractions (DBCA)
#> 6:   WA Department of Biodiversity, Conservation and Attractions (DBCA)
#>    distance_km
#>          <num>
#> 1:        0.00
#> 2:        7.62
#> 3:       29.23
#> 4:       30.90
#> 5:       37.83
#> 6:       47.78

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,
    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.2560 -31.84210     WA    268
#>                                                                   owner
#>                                                                  <char>
#> 1: WA Department of Primary Industries and Regional Development (DPIRD)
#> 2: WA Department of Primary Industries and Regional Development (DPIRD)
#> 3:                  WA Department of Fire and Emergency Services (DFES)
#> 4: WA Department of Primary Industries and Regional Development (DPIRD)
#> 5:   WA Department of Biodiversity, Conservation and Attractions (DBCA)
#> 6:   WA Department of Biodiversity, Conservation and Attractions (DBCA)
#>    distance_km
#>          <num>
#> 1:        3.23
#> 2:        7.93
#> 3:       30.79
#> 4:       31.65
#> 5:       34.61
#> 6:       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,
    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.2560 -31.84210     WA    268
#> 25:       009066        Gidgegannup  116.1976 -31.79060     WA    290
#>     station_code       station_name longitude  latitude  state elev_m
#>                                                                    owner
#>                                                                   <char>
#>  1: WA Department of Primary Industries and Regional Development (DPIRD)
#>  2:                                                                  BOM
#>  3: WA Department of Primary Industries and Regional Development (DPIRD)
#>  4:                                                                  BOM
#>  5:                                                                  BOM
#>  6:                                                                  BOM
#>  7:                                                                  BOM
#>  8:                                                                  BOM
#>  9:                                                                  BOM
#> 10:                                                                  BOM
#> 11: WA Department of Primary Industries and Regional Development (DPIRD)
#> 12:                                                                  BOM
#> 13:                  WA Department of Fire and Emergency Services (DFES)
#> 14:   WA Department of Biodiversity, Conservation and Attractions (DBCA)
#> 15:                                                                  BOM
#> 16:                                                                  BOM
#> 17:                                                                  BOM
#> 18:                                                                  BOM
#> 19:                                                                  BOM
#> 20:                                                                  BOM
#> 21:                                                                  BOM
#> 22:                                                                  BOM
#> 23:                                                                  BOM
#> 24:   WA Department of Biodiversity, Conservation and Attractions (DBCA)
#> 25:                                                                  BOM
#>                                                                    owner
#>     distance_km
#>           <num>
#>  1:    0.000000
#>  2:    3.369959
#>  3:    7.620000
#>  4:    9.878912
#>  5:   10.986728
#>  6:   20.914807
#>  7:   23.934879
#>  8:   24.889495
#>  9:   28.381350
#> 10:   28.808439
#> 11:   29.230000
#> 12:   29.790490
#> 13:   30.900000
#> 14:   37.830000
#> 15:   37.993263
#> 16:   41.128932
#> 17:   41.412805
#> 18:   42.226585
#> 19:   44.489821
#> 20:   45.457855
#> 21:   45.923973
#> 22:   46.778842
#> 23:   47.759247
#> 24:   47.780000
#> 25:   49.440793
#>     distance_km

Example 13: Finding Stations in the Southwest Agriculture Region of Western Australia

Using find_stations_in() is different than find_nearby_stations() as it finds any stations that fall within a boundary that you provide rather than using a single point to search from. For detailed examples using named places or bounding boxes, see the “weatherOz for SILO” vignette.

The {sf} object, south_west_agricultural_region, is provided with {weatherOz} under the CC BY 4.0 Licence from the Department of Primary Industries and Regional Development (DPIRD), so we can extract stations within this area of Western Australia.

First, we can plot the south_west_agricultural_region to see what it looks like.

library(weatherOz)
library(ggplot2)
library(ggthemes)
library(sf)

ggplot(south_west_agricultural_region) +
   geom_sf() +
   theme_map()
plot of chunk view_sw_ag_region

plot of chunk view_sw_ag_region

Now we can use that to find stations that fall only within that part of Western Australia. We’ll use the coordinate reference system (CRS) provided by this {sf} object and find all stations, including those that have closed.

sw_wa <- find_stations_in(
  x = south_west_agricultural_region,
  include_closed = TRUE,
  crs = sf::st_crs(south_west_agricultural_region)
)

sw_wa
#>       station_code              station_name      start        end  latitude
#>             <fctr>                    <char>     <Date>     <Date>     <num>
#>    1:       009804                     Adina 1969-01-01 2024-07-07 -33.88110
#>    2:       008000                     Ajana 1917-01-01 2024-07-07 -27.96070
#>    3:       009500                    Albany 1877-01-01 2024-07-07 -35.02890
#>    4:       009741 Albany Airport Comparison 1942-01-01 2014-01-01 -34.94140
#>    5:       010501     Aldersyde Post Office 1909-01-01 1976-01-01 -32.36670
#>   ---                                                                       
#> 1034:       008146                  Ytiniche 1913-01-01 2024-07-07 -30.07060
#> 1035:       008147                      Yuna 1909-01-01 2024-07-07 -28.32500
#> 1036:        YU001                      Yuna 2012-06-21 2024-07-07 -28.33763
#> 1037:        YU002                   Yuna NE 2016-03-24 2024-07-07 -28.20032
#> 1038:        YU003                Yuna North 2018-08-08 2024-07-07 -28.12086
#>       longitude  state elev_m
#>           <num> <char>  <num>
#>    1:  122.2167     WA     60
#>    2:  114.6336     WA    210
#>    3:  117.8808     WA      3
#>    4:  117.8022     WA     68
#>    5:  117.2833     WA     NA
#>   ---                        
#> 1034:  116.2092     WA    300
#> 1035:  114.9589     WA    270
#> 1036:  114.9898     WA    329
#> 1037:  115.2616     WA    267
#> 1038:  114.9626     WA    264
#>                                                                     source
#>                                                                     <char>
#>    1:                                          Bureau of Meteorology (BOM)
#>    2:                                          Bureau of Meteorology (BOM)
#>    3:                                          Bureau of Meteorology (BOM)
#>    4:                                          Bureau of Meteorology (BOM)
#>    5:                                          Bureau of Meteorology (BOM)
#>   ---                                                                     
#> 1034:                                          Bureau of Meteorology (BOM)
#> 1035:                                          Bureau of Meteorology (BOM)
#> 1036: WA Department of Primary Industries and Regional Development (DPIRD)
#> 1037: WA Department of Primary Industries and Regional Development (DPIRD)
#> 1038: WA Department of Primary Industries and Regional Development (DPIRD)
#>       status   wmo
#>       <char> <num>
#>    1:   open    NA
#>    2:   open    NA
#>    3:   open 94801
#>    4: closed 95802
#>    5: closed    NA
#>   ---             
#> 1034:   open    NA
#> 1035:   open    NA
#> 1036:   open    NA
#> 1037:   open    NA
#> 1038:   open    NA

We need to convert the sw_wa object from a data.table to an sf object and transform it to use the same CRS as the south_west_agricultural_region object to map the results.

sw_wa <- st_as_sf(
  x = sw_wa,
  coords = c("longitude", "latitude"),
  crs = "EPSG:4326"
)

sw_wa <- st_transform(x = sw_wa, crs = st_crs(south_west_agricultural_region))

Now we can use {ggplot2} to plot the stations indicating whether they are still open or they are closed.

ggplot(south_west_agricultural_region) +
  geom_sf(fill = "white") +
  geom_sf(data = sw_wa,
          alpha = 0.65,
          size = 2,
          aes(colour = status)) +
  theme_map()
plot of chunk plot_sw_land_div_map

plot of chunk plot_sw_land_div_map

Checking Station Uptime or Availability

Example 14: 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"
))
#> Key: <station_code>
#>    station_code station_name to9_am since9_am since12_am current_hour
#>          <fctr>       <char>  <int>     <num>      <num>        <int>
#> 1:        WS001     Westonia    100      96.6       99.3           80
#>    last24_hours last7_days_since9_am last7_days_since12_am
#>           <num>                <num>                 <num>
#> 1:         99.6                 99.9                  99.9
#>    last14_days_since9_am last14_days_since12_am month_to_date_to9_am
#>                    <int>                  <int>                <num>
#> 1:                   100                    100                 99.9
#>    month_to_date_since12_am year_to_date_to9_am year_to_date_since12_am
#>                       <num>               <int>                   <int>
#> 1:                     99.9                 100                     100

Example 15: 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"
  )
)
#> Key: <station_code>
#>    station_code station_name start_date   end_date availability_since_9_am
#>          <fctr>       <char>     <POSc>     <POSc>                   <int>
#> 1:           BI        Binnu 2018-01-01 2018-01-31                     100
#>    availability_since_12_am
#>                       <int>
#> 1:                      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 16: 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"))
#>      station_code station_name      start        end  latitude longitude  state
#>            <char>       <char>     <Date>     <Date>     <num>     <num> <char>
#>   1:        AN001    Allanooka 2012-06-19 2024-07-07 -29.06361  114.9972     WA
#>   2:        AM001       Amelup 2019-10-09 2024-07-07 -34.27083  118.2685     WA
#>   3:        SH002      Babakin 2016-06-22 2024-07-07 -32.12548  118.0041     WA
#>   4:           BA  Badgingarra 2008-11-19 2024-07-07 -30.33805  115.5395     WA
#>   5:        BP001     Balingup 2014-10-24 2024-07-07 -33.79620  116.0640     WA
#>  ---                                                                           
#> 227:           YS      Yilgarn 2008-11-01 2024-07-07 -31.91562  119.2561     WA
#> 228:        YE001    York East 2013-11-08 2024-07-07 -31.83588  116.9211     WA
#> 229:        YU001         Yuna 2012-06-21 2024-07-07 -28.33763  114.9898     WA
#> 230:        YU002      Yuna NE 2016-03-24 2024-07-07 -28.20032  115.2616     WA
#> 231:        YU003   Yuna North 2018-08-08 2024-07-07 -28.12086  114.9626     WA
#>      elev_m
#>       <int>
#>   1:    131
#>   2:    200
#>   3:    313
#>   4:    284
#>   5:    227
#>  ---       
#> 227:    468
#> 228:    229
#> 229:    329
#> 230:    267
#> 231:    264
#>                                                                    source
#>                                                                    <char>
#>   1: WA Department of Primary Industries and Regional Development (DPIRD)
#>   2: WA Department of Primary Industries and Regional Development (DPIRD)
#>   3: WA Department of Primary Industries and Regional Development (DPIRD)
#>   4: WA Department of Primary Industries and Regional Development (DPIRD)
#>   5: WA Department of Primary Industries and Regional Development (DPIRD)
#>  ---                                                                     
#> 227: WA Department of Primary Industries and Regional Development (DPIRD)
#> 228: WA Department of Primary Industries and Regional Development (DPIRD)
#> 229: WA Department of Primary Industries and Regional Development (DPIRD)
#> 230: WA Department of Primary Industries and Regional Development (DPIRD)
#> 231: WA Department of Primary Industries and Regional Development (DPIRD)
#>      status    wmo
#>      <char> <lgcl>
#>   1:   open     NA
#>   2:   open     NA
#>   3:   open     NA
#>   4:   open     NA
#>   5:   open     NA
#>  ---              
#> 227:   open     NA
#> 228:   open     NA
#> 229:   open     NA
#> 230:   open     NA
#> 231:   open     NA

Example 17: 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))
#>      station_code station_name      start        end  latitude longitude  state
#>            <char>       <char>     <Date>     <Date>     <num>     <num> <char>
#>   1:        AN001    Allanooka 2012-06-19 2024-07-07 -29.06361  114.9972     WA
#>   2:        AM001       Amelup 2019-10-09 2024-07-07 -34.27083  118.2685     WA
#>   3:        SH002      Babakin 2016-06-22 2024-07-07 -32.12548  118.0041     WA
#>   4:           BA  Badgingarra 2008-11-19 2024-07-07 -30.33805  115.5395     WA
#>   5:        BP001     Balingup 2014-10-24 2024-07-07 -33.79620  116.0640     WA
#>  ---                                                                           
#> 234:           YS      Yilgarn 2008-11-01 2024-07-07 -31.91562  119.2561     WA
#> 235:        YE001    York East 2013-11-08 2024-07-07 -31.83588  116.9211     WA
#> 236:        YU001         Yuna 2012-06-21 2024-07-07 -28.33763  114.9898     WA
#> 237:        YU002      Yuna NE 2016-03-24 2024-07-07 -28.20032  115.2616     WA
#> 238:        YU003   Yuna North 2018-08-08 2024-07-07 -28.12086  114.9626     WA
#>      elev_m
#>       <int>
#>   1:    131
#>   2:    200
#>   3:    313
#>   4:    284
#>   5:    227
#>  ---       
#> 234:    468
#> 235:    229
#> 236:    329
#> 237:    267
#> 238:    264
#>                                                                    source
#>                                                                    <char>
#>   1: WA Department of Primary Industries and Regional Development (DPIRD)
#>   2: WA Department of Primary Industries and Regional Development (DPIRD)
#>   3: WA Department of Primary Industries and Regional Development (DPIRD)
#>   4: WA Department of Primary Industries and Regional Development (DPIRD)
#>   5: WA Department of Primary Industries and Regional Development (DPIRD)
#>  ---                                                                     
#> 234: WA Department of Primary Industries and Regional Development (DPIRD)
#> 235: WA Department of Primary Industries and Regional Development (DPIRD)
#> 236: WA Department of Primary Industries and Regional Development (DPIRD)
#> 237: WA Department of Primary Industries and Regional Development (DPIRD)
#> 238: WA Department of Primary Industries and Regional Development (DPIRD)
#>      status    wmo probe_height rain_gauge_height wind_probe_heights
#>      <char> <lgcl>        <num>             <num>             <list>
#>   1:   open     NA         1.25               0.5                  3
#>   2:   open     NA         1.25               1.0                  3
#>   3:   open     NA         1.25               0.5                  3
#>   4:   open     NA         1.25               0.5                  3
#>   5:   open     NA         1.25               0.5                  3
#>  ---                                                                
#> 234:   open     NA         1.25               0.5                  3
#> 235:   open     NA         1.25               0.5                  3
#> 236:   open     NA         1.25               0.5                  3
#> 237:   open     NA         1.25               0.5                  3
#> 238:   open     NA         1.25               0.5                  3
#>      air_temperature battery_voltage delta_t dew_point pan_evaporation
#>               <lgcl>          <lgcl>  <lgcl>    <lgcl>          <lgcl>
#>   1:            TRUE            TRUE    TRUE      TRUE            TRUE
#>   2:            TRUE            TRUE    TRUE      TRUE            TRUE
#>   3:            TRUE            TRUE    TRUE      TRUE            TRUE
#>   4:            TRUE            TRUE    TRUE      TRUE            TRUE
#>   5:            TRUE            TRUE    TRUE      TRUE            TRUE
#>  ---                                                                  
#> 234:            TRUE            TRUE    TRUE      TRUE            TRUE
#> 235:            TRUE            TRUE    TRUE      TRUE            TRUE
#> 236:            TRUE            TRUE    TRUE      TRUE            TRUE
#> 237:            TRUE            TRUE    TRUE      TRUE            TRUE
#> 238:            TRUE            TRUE    TRUE      TRUE            TRUE
#>      relative_humidity barometric_pressure rainfall soil_temperature
#>                 <lgcl>              <lgcl>   <lgcl>           <lgcl>
#>   1:              TRUE               FALSE     TRUE            FALSE
#>   2:              TRUE               FALSE     TRUE            FALSE
#>   3:              TRUE               FALSE     TRUE             TRUE
#>   4:              TRUE               FALSE     TRUE             TRUE
#>   5:              TRUE               FALSE     TRUE             TRUE
#>  ---                                                                
#> 234:              TRUE               FALSE     TRUE             TRUE
#> 235:              TRUE               FALSE     TRUE             TRUE
#> 236:              TRUE               FALSE     TRUE            FALSE
#> 237:              TRUE               FALSE     TRUE             TRUE
#> 238:              TRUE               FALSE     TRUE             TRUE
#>      solar_irradiance wet_bulb  wind1  wind2  wind3 apparent_temperature
#>                <lgcl>   <lgcl> <lgcl> <lgcl> <lgcl>               <lgcl>
#>   1:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#>   2:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#>   3:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#>   4:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#>   5:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#>  ---                                                                    
#> 234:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#> 235:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#> 236:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#> 237:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#> 238:             TRUE     TRUE   TRUE  FALSE  FALSE                 TRUE
#>      eto_short eto_tall frost_condition heat_condition wind_erosion_condition
#>         <lgcl>   <lgcl>          <lgcl>         <lgcl>                 <lgcl>
#>   1:      TRUE     TRUE            TRUE           TRUE                   TRUE
#>   2:      TRUE     TRUE            TRUE           TRUE                   TRUE
#>   3:      TRUE     TRUE            TRUE           TRUE                   TRUE
#>   4:      TRUE     TRUE            TRUE           TRUE                   TRUE
#>   5:      TRUE     TRUE            TRUE           TRUE                   TRUE
#>  ---                                                                         
#> 234:      TRUE     TRUE            TRUE           TRUE                   TRUE
#> 235:      TRUE     TRUE            TRUE           TRUE                   TRUE
#> 236:      TRUE     TRUE            TRUE           TRUE                   TRUE
#> 237:      TRUE     TRUE            TRUE           TRUE                   TRUE
#> 238:      TRUE     TRUE            TRUE           TRUE                   TRUE
#>      richardson_unit chill_hour
#>               <lgcl>     <lgcl>
#>   1:            TRUE       TRUE
#>   2:            TRUE       TRUE
#>   3:            TRUE       TRUE
#>   4:            TRUE       TRUE
#>   5:            TRUE       TRUE
#>  ---                           
#> 234:            TRUE       TRUE
#> 235:            TRUE       TRUE
#> 236:            TRUE       TRUE
#> 237:            TRUE       TRUE
#> 238:            TRUE       TRUE