reformat_GSOD: Tidy and Return a Data Frame of GSOD Weather from Local Data

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/reformat_GSOD.R


This function automates cleaning and reformatting of GSOD station files in
"WMO-WBAN-YYYY.op.gz" format that have been downloaded from the United States National Center for Environmental Information's (NCEI) FTP server. Three new elements; saturation vapour pressure (es), actual vapour pressure (ea) and relative humidity are calculated and returned in the final data as well. All units are converted to International System of Units (SI), e.g. Fahrenheit to Celsius and inches to millimetres. Alternative elevation measurements are supplied for missing values or values found to be questionable based on the Consultative Group for International Agricultural Research's Consortium for Spatial Information group's (CGIAR-CSI) Shuttle Radar Topography Mission 90 metre (SRTM 90m) digital elevation data based on NASA's original SRTM 90m data.


reformat_GSOD(dsn = NULL, file_list = NULL)



User supplied file path to location of data files on local disk for tidying.


User supplied list of files of data on local disk for tidying.


Parallel processing can be enabled using plan to set up a parallel backend of your choice, e.g., future::plan("multisession"). See examples for more.

If multiple stations are given, data are summarised for each year by station, which include vapour pressure and relative humidity elements calculated from existing data in GSOD. Else, single stations are tidied and a data frame is returned.

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

Only station files in the original ".op.gz" file format are supported by this function. If you have downloaded the full annual "gsod_YYYY.tar" file you will need to extract the individual station files from the tar file first to use this function.

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").


A data frame as a tibble object of weather data.


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.”


Adam H Sparks, [email protected]


Jarvis, A., Reuter, H.I, Nelson, A., Guevara, E. (2008) Hole-filled SRTM for the globe Version 4, available from the CGIAR-CSI SRTM 90m Database

See Also

For automated downloading and tidying see the get_GSOD function which provides expanded functionality for automatically downloading and expanding annual GSOD files and cleaning station files.



# Download data to 'tempdir()'
download.file(url =
     	destfile = file.path(tempdir(), "955510-99999-2010.op.gz"),
     	mode = "wb")

# Reformat station data files in R's tempdir() directory
tbar <- reformat_GSOD(dsn = tempdir())


GSODR documentation built on Dec. 19, 2018, 5:04 p.m.