Learn R Programming

rnoaa (version 0.6.0)

ghcnd: Get all GHCND data from a single weather site

Description

This function uses ftp to access the Global Historical Climatology Network daily weather data from NOAA's FTP server for a single weather site. It requires the site identification number for that site and will pull the entire weather dataset for the site.

Usage

ghcnd(stationid, path = "~/.rnoaa/ghcnd", ...)

Arguments

stationid
A character string giving the identification of the weather station for which the user would like to pull data. To get a full and current list of stations, the user can use the ghcnd_stations function. To identify stations within a certain radius of a location, the user can use the meteo_nearby_stations function.
path
A character vector giving the path to the directory to cache the files locally. By default, the function uses ~/.rnoaa/isd.
...
Additional curl options to pass through to GET.

Value

A list object with a single slot, data, which contains the dataframe pulled from NOAA's FTP for the queried weather site. A README file with more information about the format of this file is available from NOAA (http://www1.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt). This file is formatted so each line of the file gives the daily weather observations for a single weather variable for all days of one month of one year. In addition to measurements, columns are included for certain flags, which add information on observation sources and quality and are further explained in NOAA's README file for the data.

See Also

To generate a weather dataset for a single weather site that has been cleaned to a tidier weather format, the user should use the ghcnd_search function, which calls ghcnd and then processes the output, or meteo_tidy_ghcnd, which wraps the ghcnd_search function to output a tidy dataframe rather than a list object. To pull GHCND data from multiple monitors, see meteo_pull_monitors.

Examples

Run this code
## Not run: 
# # Get data
# ghcnd(stationid = "AGE00147704")
# 
# stations <- ghcnd_stations()
# ghcnd(stations$data$id[40])
# ghcnd(stations$data$id[4000])
# ghcnd(stations$data$id[10000])
# ghcnd(stations$data$id[80000])
# ghcnd(stations$data$id[80300])
# 
# library("dplyr")
# ghcnd(stations$data$id[80300])$data %>% select(id, element) %>% slice(1:3)
# 
# # manipulate data
# ## using built in fxns
# dat <- ghcnd(stationid="AGE00147704")
# (alldat <- ghcnd_splitvars(dat))
# library("ggplot2")
# ggplot(subset(alldat$tmax, tmax >= 0), aes(date, tmax)) + geom_point()
# 
# ## using dplyr
# library("dplyr")
# dat <- ghcnd(stationid="AGE00147704")
# dat$data %>%
#  filter(element == "PRCP", year == 1909)
# 
# ## End(Not run)

Run the code above in your browser using DataLab