R script for figure in NCRN resource brief: How Geology Shapes Stream Chemistry in Parks of the National Capital Region

Wainright C . 2026. R script for figure in NCRN resource brief: How Geology Shapes Stream Chemistry in Parks of the National Capital Region. National Park Service

ANC + Karst Analysis: Figure Generation Workflow Date: 2026-10-26 Author: cwainright@nps.gov This project assembles Acid Neutralizing Capacity (ANC) data from the National Capital Region Network (NCRN), joins water‑quality measurements with metadata, identifies karst‑associated monitoring locations, and generates publication‑ready ANC figures for use in the Karst brief/article (Megan Nortrup / Ava Klink). Outputs include high‑resolution figures suitable for proofing, copy‑writing, web content, and print layouts. ---------------------------------------------------------------------- Project Structure ---------------------------------------------------------------------- ├── main.R ├── deliverable.R ├── env.R ├── renv.lock ├── R/ ├── get_anc_lookup.R ├── get_fig_data.R ├── get_karst_sites.R ├── make_figure.R └── summarize_df.R ├── data/ ├── wqp.csv └── wqp_ncrnwater_metadata.csv ---------------------------------------------------------------------- Data Sources ---------------------------------------------------------------------- The project uses two data files, both downloaded from the IRMA Data Store: - wqp.csv Water Quality Portal (WQP) results containing ANC and related parameters. Download: https://irma.nps.gov/DataStore/Reference/Profile/2317661 - wqp_ncrnwater_metadata.csv Metadata describing monitoring locations, site codes, ANC thresholds, and supporting descriptors. Download: https://irma.nps.gov/DataStore/Reference/Profile/2317661 Place these files in the data/ directory. ---------------------------------------------------------------------- R Environment and Reproducibility ---------------------------------------------------------------------- This project uses renv for dependency management. renv.lock documents all package versions for this project. Running env.R will: - initialize an renv environment - install required packages (dplyr, ggplot2, lubridate, stringr, tidyr, ragg, svglite) - snapshot the environment To reproduce the environment: source("env.R") To activate an existing renv environment: renv::activate() ---------------------------------------------------------------------- Script Overview ---------------------------------------------------------------------- main.R Interactive, prototyping‑focused workflow. Generates a single ANC figure for quick inspection. Steps: 1. Load helper functions 2. Read data and metadata 3. Select sites and date range 4. Prepare figure‑ready data 5. Generate and display the ANC figure deliverable.R Batch exporter that generates all combinations of figure variants and dimensions. Outputs are saved in the exports_anc_figs/ directory. Export formats include PNG (raster), SVG (vector, web), and PDF (vector, print). env.R Initializes the reproducible environment via renv. ---------------------------------------------------------------------- Helper Functions (R/ directory) ---------------------------------------------------------------------- get_anc_lookup.R Extracts ANC lower‑point thresholds from metadata. get_fig_data.R Merges data and metadata, tags karst sites, creates labels, filters by site/date, and prepares plot‑ready data. get_karst_sites.R Identifies monitoring locations tagged as karst. make_figure.R Builds ANC boxplots or time series, including threshold lines and color/linetype legends. summarize_df.R Internal utility summarizing counts, missingness, sites, and year ranges. ---------------------------------------------------------------------- Typical Workflow ---------------------------------------------------------------------- 1. Install/restore R environment: renv::restore() 2. Generate a figure interactively: source("main.R") 3. Export all deliverable figures: source("deliverable.R") ---------------------------------------------------------------------- Outputs ---------------------------------------------------------------------- deliverable.R creates: exports_anc_figs/ Each filename follows this pattern: anc-by-karst-YYYYMMDD_ _ . Examples: anc-by-karst-20261026_title-and-sub_pagewidth-square.png anc-by-karst-20261026_no-title-no-sub_pagewidth-short.svg ---------------------------------------------------------------------- Notes and Assumptions ---------------------------------------------------------------------- - ANC measurements must be numeric; non-numeric values are safely coerced. - Dates are filtered inclusively. - Karst classification is based on metadata text matching the phrase “for karst”. - Figure dimensions and variant definitions can be adjusted in deliverable.R. ----------------------------------------------------------------------

Type
Script
Authors
Wainright, Charles
Date of Issue
2026-11
Publisher
National Park Service
Units
ANAC , ANCM , ANTI , ARHO , BATT , BAWA , CAHE , CATO , CHOH , CLBA , CLMO , FOCI , FODU , FOFO , FOWA , FRDO , FRSC , GLEC , GREE , GRFA , GWMP , HAFE , HAHA , KEAQ , LYBA , MAMC , MANA , MEHI , MONO , NACE , NCR , OLST , OXHI , OXRU , PIMI , PISC , POHE , PRWI , ROCR , SEBE , SUIT , THIS , WOTR
Keywords
acid neutralizing capacity, ANC, Fenwick Branch, figure, karst, NCRN, R, Script, Sharpsburg Creek, stream
License
Public Domain

See also

Browse the catalog