summarizeNWS: Function summarizes National Weather Service precipitation...

View source: R/summarizeNWS.R

summarizeNWSR Documentation

Function summarizes National Weather Service precipitation geotiff files by polygon

Description

Summarize spatial data using a polygon layer to return raw values for each date and aggregate measures by month.

Usage

summarizeNWS(
  tif_addresses,
  parameter = "observed",
  input_polygon,
  polygon_names = NULL,
  create_plots = FALSE,
  func = mean,
  date_correction = -1
)

Arguments

tif_addresses

character vector with full file names for tiff files to be summarized (including entire directory and file extension). Can be created with ‘list.files(’C:/directory', full.names = TRUE)'.

parameter

character element used to select the appropriate data layers. Acceptable 'parameter' values include 'observed', 'normal', 'departure_in', and 'departure_pct'.

input_polygon

Spatvector with polygons used to summarize precipitation data. Load with 'terra::vect'. Example polygon data: https://catalog.data.gov/dataset/tiger-line-shapefile-2019-state-georgia-current-county-subdivision-state-based

polygon_names

character. Name of column in 'input_polygon' containing feature names/IDs. If left as 'NULL', features are numbered by their row in the polygon object.

create_plots

logical. Optional visualization produced for each layer. Setting this to 'TRUE' will dramatically slow down the run time.

func

function. Used to summarize the monthly data from each polygon.

date_correction

numeric. Optional correction for data date. For example, setting this to ‘-1' could be appropriate for a layer dated February 1st that captures January’s monthly precipitation totals. If no correction is desired, set to 0.

Value

list summarizeNWS containing (1) 'summary_table', a summary dataframe showing the result of 'func' applied to monthly values for Jan-Dec. More complex operations can be performed on the raw values, and (2) 'all_data', a dataframe containing the raw values from each polygon and each layer.

Examples

2+2

troyhill/SFNRC documentation built on Dec. 30, 2024, 4:32 p.m.