Learn R Programming

rnoaa (version 0.4.2)

ghcnd: Get GHCND daily data from NOAA FTP server

Description

Get GHCND daily data from NOAA FTP server

Usage

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

ghcnd_search(stationid, date_min = NULL, date_max = NULL, var = "all", path = "~/.rnoaa/ghcnd", ...)

ghcnd_splitvars(x)

ghcnd_stations(..., n = 10)

ghcnd_states(...)

ghcnd_countries(...)

ghcnd_version(...)

Arguments

stationid
Stationid to get
path
(character) A path to store the files, Default: ~/.rnoaa/isd
...
Curl options passed on to GET
date_min,date_max
(character) Minimum and maximum dates. Use together to get a date range
var
(character) Variable to get, defaults to "all", which gives back all variables in a list. To see what variables are available for a dataset, look at the dataset returned from ghcnd().
x
Input object to print methods. For ghcnd_splitvars(), the output of a call to ghcnd().
n
Number of rows to print

Examples

Run this code
## Not run: ------------------------------------
# # Get metadata
# ghcnd_states()
# ghcnd_countries()
# ghcnd_version()
# 
# # Get stations, ghcnd-stations and ghcnd-inventory merged
# (stations <- ghcnd_stations())
# 
# # Get data
# ghcnd(stationid = "AGE00147704")
# 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) %>% head
# 
# # 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)
# 
# # Search based on variable and/or date
# ghcnd_search("AGE00147704", var = "PRCP")
# ghcnd_search("AGE00147704", var = "PRCP", date_min = "1920-01-01")
# ghcnd_search("AGE00147704", var = "PRCP", date_max = "1915-01-01")
# ghcnd_search("AGE00147704", var = "PRCP", date_min = "1920-01-01", date_max = "1925-01-01")
# ghcnd_search("AGE00147704", date_min = "1920-01-01", date_max = "1925-01-01")
# ghcnd_search("AGE00147704", var = c("PRCP","TMIN"))
# ghcnd_search("AGE00147704", var = c("PRCP","TMIN"), date_min = "1920-01-01")
# ghcnd_search("AGE00147704", var="adfdf")
## ---------------------------------------------

Run the code above in your browser using DataLab