meteo_pull_monitors: Pull GHCND weather data for multiple weather monitors

Description Usage Arguments Value Note Author(s) References Examples

View source: R/helpers_ghcnd.R

Description

This function takes a vector of one or more weather station IDs. It will pull the weather data from the Global Historical Climatology Network's daily data (GHCND) for each of the stations and join them together in a single tidy dataframe. For any weather stations that the user calls that are not available by ftp from GHCND, the function will return a warning giving the station ID.

Usage

1
2
3
4
5
6
7
meteo_pull_monitors(
  monitors,
  keep_flags = FALSE,
  date_min = NULL,
  date_max = NULL,
  var = "all"
)

Arguments

monitors

A character vector listing the station IDs for all weather stations the user would like to pull. 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.

keep_flags

TRUE / FALSE for whether the user would like to keep all the flags for each weather variable. The default is to not keep the flags (FALSE). See the note below for more information on these flags.

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.

Value

A data frame of daily weather data for multiple weather monitors, converted to a tidy format. All weather variables may not exist for all weather stations. Examples of variables returned are:

There are other possible weather variables in the Global Historical Climatology Network; see http://www1.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt for a full list. If the var argument is something other than "all", then only variables included in that argument will be included in the output data frame. All variables are in the units specified in the linked file (note that, in many cases, measurements are given in tenths of the units more often used, e.g., tenths of degrees for temperature). All column names correspond to variable names in the linked file, but with all uppercase letters changed to lowercase.

Note

The weather flags, which are kept by specifying keep_flags = TRUE are:

More information on the interpretation of these flags can be found in the README file for the NCDC's Daily Global Historical Climatology Network's data at http://www1.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt

This function converts any value of -9999 to a missing value for the variables "prcp", "tmax", "tmin", "tavg", "snow", and "snwd". However, for some weather observations, there still may be missing values coded using a series of "9"s of some length. You will want to check your final data to see if there are lurking missing values given with series of "9"s.

This function may take a while to run.

Author(s)

Brooke Anderson brooke.anderson@colostate.edu

References

For more information about the data pulled with this function, see:

Menne, M.J., I. Durre, R.S. Vose, B.E. Gleason, and T.G. Houston, 2012: An overview of the Global Historical Climatology Network-Daily Database. Journal of Atmospheric and Oceanic Technology, 29, 897-910, doi:10.1175/JTECH-D-11-00103.1.

Examples

1
2
3
4
5
6
7
## Not run: 

monitors <- c("ASN00003003", "ASM00094299", "ASM00094995", "ASM00094998")
all_monitors_clean <- meteo_pull_monitors(monitors)


## End(Not run)

rnoaa documentation built on May 19, 2021, 9:13 a.m.