
Analyze water quality comprehensively with flexible data handling
Source:R/13-water-quality.R
analyze_water_quality_comprehensive.RdComplete water quality analysis with flexible data input handling, robust error checking, and comprehensive spatial integration. Supports any water quality dataset format with automatic column detection and standardized processing.
Arguments
- water_data
Water quality data in various formats:
File path (CSV, shapefile, GeoJSON)
data.frame with coordinates
sf object
List of datasets for multi-dataset analysis
- variable
Variable to analyze (auto-detected if NULL)
- region_boundary
Region boundary (optional)
- river_network
Optional river network data for context
- output_folder
Output directory (default: tempdir())
- thresholds
Named list of threshold values for classification (optional)
- coord_cols
Coordinate column names (auto-detected if NULL)
- date_column
Date/time column name (auto-detected if NULL)
- station_id_col
Station ID column name (auto-detected if NULL)
- quality_filters
Quality control filters to apply
- verbose
Print detailed progress messages
Value
List with comprehensive water quality analysis results:
water_data: Processed spatial datastatistics: Summary statistics by variable and categoryspatial_analysis: Spatial pattern analysistemporal_analysis: Temporal trends (if date data available)threshold_analysis: Threshold exceedance analysisoutput_files: Paths to generated output filesmetadata: Analysis metadata and parameters
Examples
if (FALSE) { # \dontrun{
# These examples require external data files not included with the package
# Flexible data input - auto-detects columns
results <- analyze_water_quality_comprehensive("water_stations.csv")
# Specify parameters for custom data
results <- analyze_water_quality_comprehensive(
water_data = my_data,
variable = "nitrate_concentration",
region_boundary = "Ohio",
coord_cols = c("longitude", "latitude"),
thresholds = list(
Normal = c(0, 2),
Elevated = c(2, 5),
High = c(5, 10),
Critical = c(10, Inf)
)
)
# Multi-dataset analysis
results <- analyze_water_quality_comprehensive(
water_data = list(
surface = "surface_water.csv",
groundwater = "groundwater.csv"
),
variable = "total_nitrogen"
)
} # }