procWeather: Process and plot output from getWeatherStationData

View source: R/procWeather.R

procWeatherR Documentation

Process and plot output from getWeatherStationData

Description

procWeather Take output from getWeatherStationData, get sliding window average temperatures and cumulative precipiation. Use ggplot2 to plot these.

Usage

procWeather(histWeather, years2plot = c(2016, 2017), siteLevels = NULL,
  plotit = T)

Arguments

histWeather

Output from getWeatherStationData

years2plot

Numeric, The years that will be plotted as individual lines. The other years in the dataset will be averaged into "historical" data.

siteLevels

Character, The levels to use for the names of the sites. If specified, ensure that all sites are included - these will be the only ones that will be plotted.

plotit

Logical, should a plot be drawn.

date_max

The latest data that must have data from the station. See rnoaa::meteo_nearby_stations.

limit

The maximum number of stations to search. If none of these stations have sufficient data, an error is returned. See rnoaa::meteo_nearby_stations.

verbose

Logical, should status updates be printed?

...

Not currently in use.

Details

This function iterates through NOAA weather collection sites, deterimining whether the data collected satisfies the time and datatype constraints specified.

Value

A data.frame of daily weather data for each location id. If more than one id are included, the data.frames are placed in a named list.

Examples

## Not run: 
ll = data.frame(latitude = c(27.54986,30.38398),
  longitude = c(-97.88101,-97.72938),
  id = c("KING","PKLE"),
  stringsAsFactors = F)
data(station_data)
histWeather<-getWeatherStationData(lat_lon_df = ll,
  station_data = station_data,
  date_min = "2000-01-01",
  hasCols = c("prcp","tmax","tmin"),
  date_max = "2016-12-31")
lapply(histWeather, head)
out = procWeather(histWeather=histWeather, years2plot = 2012:2016)

## End(Not run)

jtlovell/jtlTools documentation built on Jan. 17, 2024, 2:53 p.m.