Learn R Programming

rnoaa (version 0.4.2)

isd: Get NOAA ISD/ISH data from NOAA FTP server.

Description

Get NOAA ISD/ISH data from NOAA FTP server.

Usage

isd(usaf, wban, year, path = "~/.rnoaa/isd", overwrite = TRUE, ...)

isd_stations(...)

Arguments

usaf,wban
(character) USAF and WBAN code. Required
year
(numeric) One of the years from 1901 to the current year. Required.
path
(character) A path to store the files, a directory. Default: ~/.rnoaa/isd. Required.
overwrite
(logical) To overwrite the path to store files in or not, Default: TRUE
...
Curl options passed on to GET

Details

This function first looks for whether the data for your specific query has already been downloaded previously in the directory given by the path parameter. If not found, the data is requested form NOAA's FTP server. The first time a dataset is pulled down we must a) download the data, b) process the data, and c) save a .csv file to disk. The next time the same data is requested, we only have to read back in the .csv file, and is quite fast. The processing can take quite a long time since the data is quite messy and takes a bunch of regex to split apart text strings. See examples below for different behavior.

References

ftp://ftp.ncdc.noaa.gov/pub/data/noaa/

Examples

Run this code
## Not run: ------------------------------------
# # Get station table
# stations <- isd_stations()
# head(stations)
# 
# # Get data
# (res <- isd(usaf="011490", wban="99999", year=1986))
# (res <- isd(usaf="011690", wban="99999", year=1993))
# (res <- isd(usaf="172007", wban="99999", year=2015))
# (res <- isd(usaf="702700", wban="00489", year=2015))
# 
# # The first time a dataset is requested takes longer
# system.time( isd(usaf="782680", wban="99999", year=2011) )
# system.time( isd(usaf="782680", wban="99999", year=2011) )
# 
# # Optionally pass in curl options
# res <- isd(usaf="011490", wban="99999", year=1986, config = verbose())
## ---------------------------------------------

Run the code above in your browser using DataLab