ghcnd_search: Get a cleaned version of GHCND data from a single weather...

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

View source: R/ghcnd.R

Description

This function uses ftp to access the Global Historical Climatology Network daily weather data from NOAA's FTP server for a single weather monitor site. It requires the site identification number for that site and will pull the entire weather dataset for the site. It will then clean this data to convert it to a tidier format and will also, if requested, filter it to a certain date range and to certain weather variables.

Usage

1
2
ghcnd_search(stationid, date_min = NULL, date_max = NULL, var = "all",
  ...)

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.

date_min

A character string giving the earliest date of the daily weather time series that the user would like in the final output. This character string should be formatted as "yyyy-mm-dd". If not specified, the default is to keep all daily data for the queried weather site from the earliest available date.

date_max

A character string giving the latest date of the daily weather time series that the user would like in the final output. This character string should be formatted as "yyyy-mm-dd". If not specified, the default is to keep all daily data for the queried weather site through the most current available date.

var

A character vector specifying either "all" (pull all available weather parameters for the site) or the weather parameters to keep in the final data (e.g., c("TMAX", "TMIN") to only keep maximum and minimum temperature). Example choices for this argument include:

  • PRCP: Precipitation, in tenths of millimeters

  • TAVG: Average temperature, in tenths of degrees Celsius

  • TMAX: Maximum temperature, in tenths of degrees Celsius

  • TMIN: Minimum temperature, in tenths of degrees Celsius

A full list of possible weather variables is available in NOAA's README file for the GHCND data (https://www1.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt). Most weather stations will only have a small subset of all the possible weather variables, so the data generated by this function may not include all of the variables the user specifies through this argument.

...

Additional curl options to pass through to GET.

Value

A list object with slots for each of the available specified weather variables. Each element in the list is a separate time series dataframe with daily observations, as well as flag values, for one of the weather variables. The flag values give information on the quality and source of each observation; see the NOAA README file linked above for more information.

Note

This function calls ghcnd, which will download and save data from all available dates and weather variables for the queried weather station. The step of limiting the dataset to only certain dates and / or weather variables, using the date_min, date_max, and var arguments, does not occur until after the full data has been pulled.

Author(s)

Scott Chamberlain myrmecocystus@gmail.com, Adam Erickson adam.erickson@ubc.ca

See Also

meteo_pull_monitors, meteo_tidy_ghcnd

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# 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")

## End(Not run)

leighseverson/rnoaa documentation built on May 21, 2019, 3:06 a.m.