This function automates downloading, cleaning, reformatting of data from the Global Surface Summary of the Day (GSOD) data provided by the US National Centers for Environmental Information (NCEI), Three additional useful elements: saturation vapour pressure (es), actual vapour pressure (ea) and relative humidity (RH) are calculated and returned in the final data frame using the improved August-Roche-Magnus approximation (Alduchov and Eskridge 1996).

get_GSOD(
  years,
  station = NULL,
  country = NULL,
  max_missing = NULL,
  agroclimatology = FALSE
)

Arguments

years

Year(s) of weather data to download.

station

Optional. Specify a station or multiple stations for which to retrieve, check and clean weather data using STATION. The NCEI reports years for which the data are available. This function checks against these years. However, not all cases are properly documented and in some cases files may not exist for download even though it is indicated that data was recorded for the station for a particular year. If a station is specified that does not have an existing file on the server, this function will silently fail and move on to existing files for download and cleaning.

country

Optional. Specify a country for which to retrieve weather data; full name, 2 or 3 letter ISO or 2 letter FIPS codes can be used. All stations within the specified country will be returned.

max_missing

Optional. The maximum number of days allowed to be missing from a station's data before it is excluded from final file output.

agroclimatology

Optional. Logical. Only clean data for stations between latitudes 60 and -60 for agroclimatology work, defaults to `FALSE`. Set to `TRUE` to include only stations within the confines of these latitudes.

Value

A data frame as a data.table object of GSOD weather data.

Details

All units are converted to International System of Units (SI), e.g., Fahrenheit to Celsius and inches to millimetres.

Data summarise each year by station, which include vapour pressure and relative humidity elements calculated from existing data in GSOD.

All missing values in resulting files are represented as NA regardless of which field they occur in.

For a complete list of the fields and description of the contents and units, please refer to Appendix 1 in the GSODR vignette, vignette("GSODR", package = "GSODR").

For more information see the description of the data provided by NCEI, https://www7.ncdc.noaa.gov/CDO/GSOD_DESC.txt.

Note

GSODR attempts to validate year and station combination requests, however, in certain cases the start and end date may encompass years where no data is available. In these cases no data will be returned. It is suggested that the user check the latest data availability for the station(s) desired using get_inventory as this list is frequently updated by the NCEI and is not shipped with GSODR.

While GSODR does not distribute GSOD weather data, users of the data should note the conditions that the U.S. NCEI places upon the GSOD data. “The following data and products may have conditions placed on their international commercial use. They can be used within the U.S. or for non- commercial international activities without restriction. The non-U.S. data cannot be redistributed for commercial purposes. Re-distribution of these data by others must provide this same notification. A log of IP addresses accessing these data and products will be maintained and may be made available to data providers.”

References

Alduchov, O.A. and Eskridge, R.E., 1996. Improved Magnus form approximation of saturation vapor pressure. Journal of Applied Meteorology and Climatology, 35(4), pp.601-609. DOI: <10.1175

See also

Author

Adam H. Sparks, adamhsparks@gmail.com

Examples

# \donttest{ # Download weather station data for Toowoomba, Queensland for 2010 (tbar <- get_GSOD(years = 2010, station = "955510-99999"))
#> STNID NAME CTRY COUNTRY_NAME ISO2C ISO3C STATE #> 1: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 2: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 3: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 4: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 5: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> --- #> 361: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 362: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 363: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 364: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> 365: 955510-99999 TOOWOOMBA AIRPORT AS AUSTRALIA AU AUS #> LATITUDE LONGITUDE ELEVATION BEGIN END YEARMODA YEAR MONTH DAY #> 1: -27.55 151.917 642 19980301 20210116 2010-01-01 2010 1 1 #> 2: -27.55 151.917 642 19980301 20210116 2010-01-02 2010 1 2 #> 3: -27.55 151.917 642 19980301 20210116 2010-01-03 2010 1 3 #> 4: -27.55 151.917 642 19980301 20210116 2010-01-04 2010 1 4 #> 5: -27.55 151.917 642 19980301 20210116 2010-01-05 2010 1 5 #> --- #> 361: -27.55 151.917 642 19980301 20210116 2010-12-27 2010 12 27 #> 362: -27.55 151.917 642 19980301 20210116 2010-12-28 2010 12 28 #> 363: -27.55 151.917 642 19980301 20210116 2010-12-29 2010 12 29 #> 364: -27.55 151.917 642 19980301 20210116 2010-12-30 2010 12 30 #> 365: -27.55 151.917 642 19980301 20210116 2010-12-31 2010 12 31 #> YDAY TEMP TEMP_ATTRIBUTES DEWP DEWP_ATTRIBUTES SLP SLP_ATTRIBUTES STP #> 1: 1 21.2 8 17.9 8 1013.4 8 942.0 #> 2: 2 23.2 8 19.4 8 1010.5 8 939.3 #> 3: 3 21.4 8 18.9 8 1012.3 8 940.9 #> 4: 4 18.9 8 16.4 8 1015.7 8 944.1 #> 5: 5 20.5 8 16.4 8 1015.5 8 944.0 #> --- #> 361: 361 18.9 8 17.3 8 1005.8 8 934.8 #> 362: 362 17.7 8 14.7 8 1013.2 8 941.6 #> 363: 363 19.8 8 15.4 8 1014.4 8 942.7 #> 364: 364 21.4 8 16.1 8 1014.6 8 942.9 #> 365: 365 21.1 8 15.7 8 1013.9 8 942.3 #> STP_ATTRIBUTES VISIB VISIB_ATTRIBUTES WDSP WDSP_ATTRIBUTES MXSPD GUST MAX #> 1: 8 NA 0 4.3 8 6.7 NA 25.8 #> 2: 8 NA 0 3.7 8 5.1 NA 26.5 #> 3: 8 14.3 6 7.6 8 10.3 NA 28.7 #> 4: 8 23.3 4 8.7 8 10.3 NA 24.1 #> 5: 8 NA 0 7.5 8 10.8 NA 24.6 #> --- #> 361: 8 25.3 5 7.2 8 11.8 NA 22.1 #> 362: 8 NA 0 11.2 8 14.4 NA 21.5 #> 363: 8 NA 0 6.6 8 9.3 NA 24.0 #> 364: 8 NA 0 7.2 8 9.3 NA 26.5 #> 365: 8 NA 0 7.5 8 9.3 NA 26.5 #> MAX_ATTRIBUTES MIN MIN_ATTRIBUTES PRCP PRCP_ATTRIBUTES SNDP I_FOG #> 1: <NA> 17.8 <NA> 1.5 G NA NA #> 2: <NA> 19.1 <NA> 0.3 G NA NA #> 3: <NA> 19.3 * 19.8 G NA NA #> 4: <NA> 16.9 * 1.0 G NA NA #> 5: <NA> 16.7 <NA> 0.3 G NA NA #> --- #> 361: <NA> 17.9 * 42.9 G NA NA #> 362: <NA> 15.4 * 0.3 G NA NA #> 363: <NA> 15.0 <NA> 0.0 G NA NA #> 364: <NA> 15.0 <NA> 0.0 G NA NA #> 365: <NA> 16.5 <NA> 0.0 G NA NA #> I_RAIN_DRIZZLE I_SNOW_ICE I_HAIL I_THUNDER I_TORNADO_FUNNEL EA ES RH #> 1: NA NA NA NA NA 2.0 2.5 81.5 #> 2: NA NA NA NA NA 2.2 2.8 79.2 #> 3: NA NA NA NA NA 2.2 2.5 85.7 #> 4: NA NA NA NA NA 1.9 2.2 85.4 #> 5: NA NA NA NA NA 1.9 2.4 77.3 #> --- #> 361: NA NA NA NA NA 2.0 2.2 90.4 #> 362: NA NA NA NA NA 1.7 2.0 82.6 #> 363: NA NA NA NA NA 1.7 2.3 75.8 #> 364: NA NA NA NA NA 1.8 2.5 71.8 #> 365: NA NA NA NA NA 1.8 2.5 71.3
# Download weather data for the year 1929 (w_1929 <- get_GSOD(years = 1929))
#> STNID NAME CTRY COUNTRY_NAME ISO2C ISO3C STATE LATITUDE #> 1: 030050-99999 LERWICK UK UNITED KINGDOM GB GBR 60.133 #> 2: 030050-99999 LERWICK UK UNITED KINGDOM GB GBR 60.133 #> 3: 030050-99999 LERWICK UK UNITED KINGDOM GB GBR 60.133 #> 4: 030050-99999 LERWICK UK UNITED KINGDOM GB GBR 60.133 #> 5: 030050-99999 LERWICK UK UNITED KINGDOM GB GBR 60.133 #> --- #> 2077: 990061-99999 <NA> <NA> <NA> <NA> <NA> <NA> NA #> 2078: 990061-99999 <NA> <NA> <NA> <NA> <NA> <NA> NA #> 2079: 990061-99999 <NA> <NA> <NA> <NA> <NA> <NA> NA #> 2080: 990061-99999 <NA> <NA> <NA> <NA> <NA> <NA> NA #> 2081: 990061-99999 <NA> <NA> <NA> <NA> <NA> <NA> NA #> LONGITUDE ELEVATION BEGIN END YEARMODA YEAR MONTH DAY YDAY TEMP #> 1: -1.183 84 19291001 20210116 1929-10-01 1929 10 1 274 7.4 #> 2: -1.183 84 19291001 20210116 1929-10-02 1929 10 2 275 9.7 #> 3: -1.183 84 19291001 20210116 1929-10-03 1929 10 3 276 9.4 #> 4: -1.183 84 19291001 20210116 1929-10-04 1929 10 4 277 7.6 #> 5: -1.183 84 19291001 20210116 1929-10-05 1929 10 5 278 8.1 #> --- #> 2077: NA 3 NA NA 1929-12-26 1929 12 26 360 18.7 #> 2078: NA 3 NA NA 1929-12-27 1929 12 27 361 20.6 #> 2079: NA 3 NA NA 1929-12-29 1929 12 29 363 18.4 #> 2080: NA 3 NA NA 1929-12-30 1929 12 30 364 16.8 #> 2081: NA 3 NA NA 1929-12-31 1929 12 31 365 15.5 #> TEMP_ATTRIBUTES DEWP DEWP_ATTRIBUTES SLP SLP_ATTRIBUTES STP #> 1: 4 4.4 4 1001.6 4 NA #> 2: 4 7.3 4 977.6 4 NA #> 3: 4 5.4 4 975.7 4 NA #> 4: 4 3.6 4 992.0 4 NA #> 5: 4 5.3 4 997.8 4 NA #> --- #> 2077: 24 7.2 24 NA 0 14.5 #> 2078: 24 14.0 24 NA 0 13.1 #> 2079: 24 15.8 24 NA 0 15.3 #> 2080: 24 14.5 24 NA 0 16.7 #> 2081: 24 13.0 24 NA 0 17.7 #> STP_ATTRIBUTES VISIB VISIB_ATTRIBUTES WDSP WDSP_ATTRIBUTES MXSPD GUST #> 1: 0 27.5 4 2.3 4 4.6 NA #> 2: 0 15.0 4 9.0 4 15.4 NA #> 3: 0 17.5 4 5.1 4 12.3 NA #> 4: 0 10.0 4 7.8 4 19.0 NA #> 5: 0 12.6 4 3.7 4 6.7 NA #> --- #> 2077: 24 0.0 24 NA 0 NA NA #> 2078: 24 0.0 24 NA 0 NA NA #> 2079: 24 0.0 24 NA 0 NA NA #> 2080: 24 0.0 24 NA 0 NA NA #> 2081: 24 0.0 24 NA 0 NA NA #> MAX MAX_ATTRIBUTES MIN MIN_ATTRIBUTES PRCP PRCP_ATTRIBUTES SNDP I_FOG #> 1: 10.6 <NA> 6.7 * 0 I NA NA #> 2: 11.7 * 6.7 <NA> NA <NA> NA NA #> 3: 11.7 <NA> 7.8 <NA> NA <NA> NA NA #> 4: 11.7 <NA> 6.7 <NA> NA <NA> NA NA #> 5: 8.9 * 6.1 <NA> NA <NA> NA NA #> --- #> 2077: 21.3 * 17.4 * 0 I NA NA #> 2078: 23.0 * 18.5 * 0 I NA NA #> 2079: 20.7 * 16.9 * 0 I NA NA #> 2080: 18.0 * 15.7 * 0 I NA NA #> 2081: 17.4 * 14.6 * 0 I NA NA #> I_RAIN_DRIZZLE I_SNOW_ICE I_HAIL I_THUNDER I_TORNADO_FUNNEL EA ES RH #> 1: NA NA NA NA NA 0.8 1.0 81.3 #> 2: NA NA NA NA NA 1.0 1.2 85.0 #> 3: NA NA NA NA NA 0.9 1.2 76.1 #> 4: NA NA NA NA NA 0.8 1.0 75.8 #> 5: NA NA NA NA NA 0.9 1.1 82.5 #> --- #> 2077: NA NA NA NA NA 1.0 2.2 47.1 #> 2078: NA NA NA NA NA 1.6 2.4 65.9 #> 2079: NA NA NA NA NA 1.8 2.1 84.8 #> 2080: NA NA NA NA NA 1.6 1.9 86.3 #> 2081: NA NA NA NA NA 1.5 1.8 85.1
# Download weather data for the year 1929 for Ireland (ie_1929 <- get_GSOD(years = 1929, country = "Ireland"))
#> STNID NAME CTRY COUNTRY_NAME ISO2C ISO3C STATE #> 1: 039530-99999 VALENTIA OBSERVATORY EI IRELAND IE IRL #> 2: 039530-99999 VALENTIA OBSERVATORY EI IRELAND IE IRL #> 3: 039530-99999 VALENTIA OBSERVATORY EI IRELAND IE IRL #> 4: 039530-99999 VALENTIA OBSERVATORY EI IRELAND IE IRL #> 5: 039530-99999 VALENTIA OBSERVATORY EI IRELAND IE IRL #> --- #> 265: 039800-99999 MALIN HEAD EI IRELAND IE IRL #> 266: 039800-99999 MALIN HEAD EI IRELAND IE IRL #> 267: 039800-99999 MALIN HEAD EI IRELAND IE IRL #> 268: 039800-99999 MALIN HEAD EI IRELAND IE IRL #> 269: 039800-99999 MALIN HEAD EI IRELAND IE IRL #> LATITUDE LONGITUDE ELEVATION BEGIN END YEARMODA YEAR MONTH DAY #> 1: 51.933 -10.250 30 19260102 20210116 1929-10-01 1929 10 1 #> 2: 51.933 -10.250 30 19260102 20210116 1929-10-02 1929 10 2 #> 3: 51.933 -10.250 30 19260102 20210116 1929-10-03 1929 10 3 #> 4: 51.933 -10.250 30 19260102 20210116 1929-10-04 1929 10 4 #> 5: 51.933 -10.250 30 19260102 20210116 1929-10-05 1929 10 5 #> --- #> 265: 55.367 -7.333 25 19260701 20210116 1929-12-27 1929 12 27 #> 266: 55.367 -7.333 25 19260701 20210116 1929-12-28 1929 12 28 #> 267: 55.367 -7.333 25 19260701 20210116 1929-12-29 1929 12 29 #> 268: 55.367 -7.333 25 19260701 20210116 1929-12-30 1929 12 30 #> 269: 55.367 -7.333 25 19260701 20210116 1929-12-31 1929 12 31 #> YDAY TEMP TEMP_ATTRIBUTES DEWP DEWP_ATTRIBUTES SLP SLP_ATTRIBUTES STP #> 1: 274 11.8 5 9.2 4 1011.8 4 NA #> 2: 275 13.0 5 7.5 4 1001.3 4 NA #> 3: 276 11.4 4 4.6 4 1000.2 4 NA #> 4: 277 7.4 5 5.9 4 1002.9 5 NA #> 5: 278 9.7 5 6.7 4 993.4 5 NA #> --- #> 265: 361 5.2 4 3.6 4 996.0 4 NA #> 266: 362 3.1 5 2.8 4 991.6 5 NA #> 267: 363 7.4 4 5.4 4 978.1 4 NA #> 268: 364 5.7 5 4.7 4 997.2 5 NA #> 269: 365 6.6 5 3.9 4 1010.8 5 NA #> STP_ATTRIBUTES VISIB VISIB_ATTRIBUTES WDSP WDSP_ATTRIBUTES MXSPD GUST MAX #> 1: 0 20.8 5 6.9 5 15.4 NA 15.6 #> 2: 0 26.1 5 9.9 5 12.3 NA 16.7 #> 3: 0 27.5 4 10.4 4 19.0 NA 14.4 #> 4: 0 22.9 5 6.8 5 9.3 NA 12.8 #> 5: 0 26.1 5 4.7 5 9.3 NA 12.8 #> --- #> 265: 0 12.6 4 6.9 4 9.3 NA 7.8 #> 266: 0 8.9 5 7.2 5 9.3 NA 5.6 #> 267: 0 12.6 4 13.1 4 15.4 NA 10.6 #> 268: 0 20.0 5 6.9 5 9.3 NA 7.8 #> 269: 0 20.0 5 10.0 5 12.3 NA 7.8 #> MAX_ATTRIBUTES MIN MIN_ATTRIBUTES PRCP PRCP_ATTRIBUTES SNDP I_FOG #> 1: * 6.7 <NA> 1.0 E NA 1 #> 2: <NA> 11.7 <NA> 2.0 E NA 1 #> 3: <NA> 9.4 <NA> NA <NA> NA 1 #> 4: <NA> -2.2 * 2.0 E NA 1 #> 5: <NA> 7.8 <NA> 7.1 E NA 1 #> --- #> 265: <NA> 3.9 <NA> NA <NA> NA 1 #> 266: <NA> 1.7 <NA> 1.0 E NA 1 #> 267: * 4.4 <NA> NA <NA> NA 1 #> 268: * 3.9 <NA> 0.5 E NA 1 #> 269: <NA> 2.8 <NA> 5.1 E NA 1 #> I_RAIN_DRIZZLE I_SNOW_ICE I_HAIL I_THUNDER I_TORNADO_FUNNEL EA ES RH #> 1: NA NA NA NA NA 1.2 1.4 84.1 #> 2: NA NA NA NA NA 1.0 1.5 69.3 #> 3: NA NA NA NA NA 0.8 1.3 63.0 #> 4: NA NA NA NA NA 0.9 1.0 90.2 #> 5: NA NA NA NA NA 1.0 1.2 81.6 #> --- #> 265: NA NA NA NA NA 0.8 0.9 89.4 #> 266: NA NA NA NA NA 0.7 0.8 97.9 #> 267: NA NA NA NA NA 0.9 1.0 87.1 #> 268: NA NA NA NA NA 0.9 0.9 93.3 #> 269: NA NA NA NA NA 0.8 1.0 82.9
# }