Skip to contents

Function to create the field groundwater level data plot.

Usage

gwl_plot_field(
  gwl_data,
  plot_title = "",
  parameter_cd = NA,
  date_col = "lev_dt",
  value_col = NA,
  approved_col = "lev_age_cd",
  flip = TRUE,
  y_label = "",
  subtitle = "U.S. Geological Survey"
)

gwl_plot_all(
  gw_level_dv,
  gwl_data,
  parameter_cd = NA,
  date_col = NA,
  value_col = NA,
  approved_col = NA,
  stat_cd = NA,
  y_label = "",
  subtitle = "U.S. Geological Survey",
  plot_title = "",
  add_trend = FALSE,
  n_years = 10,
  POR_trend = TRUE,
  flip = FALSE,
  days_required_per_month = 14
)

Arguments

gwl_data

data frame returned from readNWISgwl, or data frame with a date, value, and approval columns. Using the convention: lev_dt (representing date), lev_age_cd (representing approval code), and lev_va or sl_lev_va (representing value) will allow defaults to work. Use NULL for no discrete data.

plot_title

character, title for plot.

parameter_cd

If data in gw_level_dv comes from NWIS, the parameter_cd can be used to define the value_col. If the data doesn't come directly from NWIS services, this can be set to NA,and this argument will be ignored.

date_col

the name of the date column. The default is NA, in which case, the code will try to get the column name automatically based on NWIS naming conventions. If both gw_level_dv and gwl_data data frames require custom column names, the first value of this input defines the date column for gw_level_dv, and the second defines gwl_data.

value_col

the name of the value column. The default is NA, in which case, the code will try to get the column name automatically based on NWIS naming conventions. If both gw_level_dv and gwl_data data frames require custom column names, the first value of this input defines the value column for gw_level_dv, and the second defines gwl_data.

approved_col

the name of the column to get provisional/approved status. The default is NA, in which case, the code will try to get the column name automatically based on NWIS naming conventions. If both gw_level_dv and gwl_data data frames require custom column names, the first value of this input defines the approval column for gw_level_dv, and the second defines gwl_data.

flip

logical. If TRUE, flips the y axis so that the smallest number is on top. Default is TRUE.

y_label

character for y-axis label. Consider using readNWISpCode for USGS parameter_nm.

subtitle

character. Sub-title for plot, default is "U.S. Geological Survey".

gw_level_dv

data frame, daily groundwater level data. Often obtained from readNWISdv. Use NULL for no daily data.

stat_cd

If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col.

add_trend

logical. Uses trend_test.

n_years

integer. This is the number of years to calculate the trend on. Default is 10. This can be a vector of years.

POR_trend

a logical indicating whether to include a trend test for the full period of record. Default is TRUE.

days_required_per_month

integer. Number of days required per month. Default is 14. Only used if add_trend is TRUE using daily data.

Examples


# site <- "263819081585801"
# gwl_data <- dataRetrieval::readNWISgwl(site)

# Using package example data:
gwl_data <- L2701_example_data$Discrete
plot_title <- attr(gwl_data, "siteInfo")[["station_nm"]]
pcodes <- dataRetrieval::readNWISpCode(unique(gwl_data$parameter_cd))
gwl_plot_field(gwl_data, 
               plot_title = plot_title, 
               parameter_cd = "62610",
               flip = FALSE,
               y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"])

gwl_plot_field(gwl_data, 
               plot_title = plot_title,
               y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62611"], 
               parameter_cd = "62611",
               flip = FALSE)

gwl_plot_field(gwl_data,  
               plot_title = plot_title,
               y_label = pcodes$parameter_nm[pcodes$parameter_cd == "72019"], 
               parameter_cd = "72019",
               flip = TRUE)

# site <- "263819081585801"
parameterCd <- "62610"
# statCd <- "00001"
# gw_level_dv <- dataRetrieval::readNWISdv(site, parameterCd, statCd = statCd)
# Using package example data:
gw_level_dv <- L2701_example_data$Daily
gwl_data <- L2701_example_data$Discrete
plot_title <- attr(gwl_data, "siteInfo")[["station_nm"]]
pcodes <- dataRetrieval::readNWISpCode(unique(gwl_data$parameter_cd))

gwl_plot_all(gw_level_dv, 
             NULL, 
             parameter_cd = "62610",
             plot_title = plot_title,
             y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"],
             flip = TRUE) 


gwl_plot_all(gw_level_dv, 
             gwl_data, 
             parameter_cd = "62610",
             plot_title = plot_title,
             y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"],
             add_trend = TRUE,
             flip = FALSE)

             
             
gwl_plot_all(gw_level_dv,
             gwl_data,
             parameter_cd = "62610",
             n_years = c(5, 10, 20),
             POR_trend = TRUE,
             y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"],
             plot_title = plot_title,
             add_trend = TRUE)

             
gwl_plot_all(NULL, 
             gwl_data, 
             parameter_cd = "62610",
             plot_title = plot_title, 
             y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"])


gwl_plot_all(NULL, 
             gwl_data, 
             parameter_cd = "62610",
             plot_title = plot_title,
             y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"],
             add_trend = TRUE)