The riem package allows to get weather data from ASOS stations (airports) via the awesome website of the Iowa Environment Mesonet.

Installation

Install the package with:

Or install the development version using devtools with:

library("devtools")
install_github("ropenscilabs/riem")

Get available networks

## # A tibble: 267 x 2
##    code     name                     
##    <chr>    <chr>                    
##  1 AE__ASOS United Arab Emirates ASOS
##  2 AF__ASOS Afghanistan ASOS         
##  3 AG__ASOS Antigua and Barbuda ASOS 
##  4 AI__ASOS Anguilla ASOS            
##  5 AK_ASOS  Alaska ASOS              
##  6 AL__ASOS Albania ASOS             
##  7 AL_ASOS  Alabama ASOS             
##  8 AM__ASOS Armenia ASOS             
##  9 AN__ASOS Netherlands Antilles ASOS
## 10 AO__ASOS Angola ASOS              
## # … with 257 more rows

Get available stations for one network

riem_stations(network = "IN__ASOS") 
## No encoding supplied: defaulting to UTF-8.
## # A tibble: 97 x 4
##    id    name            lon   lat
##    <chr> <chr>         <dbl> <dbl>
##  1 VEAT  Agartala       91.2  23.9
##  2 VOAT  Agatti Island  72.2  10.8
##  3 VIAG  Agra           78.0  27.2
##  4 VAAH  Ahmedabad      72.6  23.1
##  5 VELP  Aizwal         92.6  23.8
##  6 VIAL  Allahabad      81.7  25.4
##  7 VIAR  Amritsar       74.9  31.6
##  8 VAAU  Aurangabad     75.4  19.9
##  9 VEBD  Baghdogra      88.3  26.6
## 10 VOBG  Bangalore      77.7  12.9
## # … with 87 more rows

Get measures for one station

Possible variables are (copied from here, see also the ASOS user guide)

  • station: three or four character site identifier

  • valid: timestamp of the observation (UTC)

  • tmpf: Air Temperature in Fahrenheit, typically @ 2 meters

  • dwpf: Dew Point Temperature in Fahrenheit, typically @ 2 meters

  • relh: Relative Humidity in %

  • drct: Wind Direction in degrees from north

  • sknt: Wind Speed in knots

  • p01i: One hour precipitation for the period from the observation time to the time of the previous hourly precipitation reset. This varies slightly by site. Values are in inches. This value may or may not contain frozen precipitation melted by some device on the sensor or estimated by some other means. Unfortunately, we do not know of an authoritative database denoting which station has which sensor.

  • alti: Pressure altimeter in inches

  • mslp: Sea Level Pressure in millibar

  • vsby: Visibility in miles

  • gust: Wind Gust in knots

  • skyc1: Sky Level 1 Coverage

  • skyc2: Sky Level 2 Coverage

  • skyc3: Sky Level 3 Coverage

  • skyc4: Sky Level 4 Coverage

  • skyl1: Sky Level 1 Altitude in feet

  • skyl2: Sky Level 2 Altitude in feet

  • skyl3: Sky Level 3 Altitude in feet

  • skyl4: Sky Level 4 Altitude in feet

  • presentwx: Present Weather Codes (space seperated), see e.g. this manual for further explanations.

  • feel: Apparent Temperature (Wind Chill or Heat Index) in degF

  • ice_accretion_1hr: Ice Accretion over 1 Hour in inch

  • ice_accretion_3hr: Ice Accretion over 3 Hour in inch

  • ice_accretion_6hr: Ice Accretion over 6 Hour in inch

  • relh: Relative Humidity in %

  • metar: unprocessed reported observation in METAR format

  • peak_wind_gust: Wind gust in knots from the METAR PK WND remark, this value may be different than the value found in the gust field. The gust field is derived from the standard METAR wind report.

  • peak_wind_drct: The wind direction in degrees North denoted in the METAR PK WND remark.

  • peak_wind_time: The timestamp of the PK WND value in the same timezone as the valid field and controlled by the tz parameter.

measures <- riem_measures(station = "VOHY", date_start = "2000-01-01", date_end = "2016-04-22") 
head(measures)
## # A tibble: 6 x 31
##   station valid                 lon   lat  tmpf  dwpf  relh  drct  sknt  p01i
##   <chr>   <dttm>              <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 VOHY    2000-01-01 00:00:00  78.5  17.5  61.5  57.4  86.3     0     0    NA
## 2 VOHY    2000-01-01 01:40:00  78.5  17.5  64.4  60.8  88.1     0     0    NA
## 3 VOHY    2000-01-01 02:40:00  78.5  17.5  69.8  60.8  73.1   140     5    NA
## 4 VOHY    2000-01-01 03:00:00  78.5  17.5  68    61.7  80.3   140     4    NA
## 5 VOHY    2000-01-01 03:40:00  78.5  17.5  71.6  62.6  73.3   140     5    NA
## 6 VOHY    2000-01-01 05:40:00  78.5  17.5  75.2  55.4  50.2    90     6    NA
## # … with 21 more variables: alti <dbl>, mslp <dbl>, vsby <dbl>, gust <dbl>,
## #   skyc1 <chr>, skyc2 <chr>, skyc3 <chr>, skyc4 <chr>, skyl1 <dbl>,
## #   skyl2 <dbl>, skyl3 <dbl>, skyl4 <dbl>, wxcodes <chr>,
## #   ice_accretion_1hr <lgl>, ice_accretion_3hr <lgl>, ice_accretion_6hr <lgl>,
## #   peak_wind_gust <lgl>, peak_wind_drct <lgl>, peak_wind_time <lgl>,
## #   feel <dbl>, metar <chr>

For conversion of wind speed or temperature into other units, see this package.