Learn R Programming

waterquality

The main purpose of waterquality is to quickly and easily convert satellite-based reflectance imagery into one or many well-known water quality indices designed for the detection of Harmful Algal Blooms (HABs) using the following pigment proxies: chlorophyll-a, blue-green algae (phycocyanin), and turbidity. Currently, this package is able to process 40 algorithms for the following satellite-based imagers: WorldView-2, Sentinel-2, Landsat-8, MODIS, MERIS, and OLCI. In order to improve the aesthetics of the wq_calc() output, a series of Map_WQ() functions were developed to help reduce technical barriers and simplify the complexities in selecting a map layout. Additional functionality of the package includes a series of extract_lm() functions that wrap the “Fitting Linear Models” and “caret” packages to quickly generate crossvalidated linear models and standardized outputs (r2, p-value, slope, intercept of the global lm model & average r2, average RMSE, average MAE of crossvalidated model) for any number of algorithm and water quality parameter combinations. It is important to note that the extract_lm() functions require ground-truth data in order to develop the models. For a more detailed look into the full functionality of waterquality, please view “Introduction to the waterquality package”. For a broader look into how to apply this tool into a research workflow or for more information on topics such as data acquisition, image pre-processing, or results, see our publication entitled “Waterquality: An Open-Source R Package for the Detection and Quantification of Cyanobacterial Harmful Algal Blooms and Water Quality”.

Additionally, we have recently developed and published a complementary python-based version of waterquality compatible with ESRI ArcGIS and ArcPro. For more information please visit “waterquality for ArcGIS Pro Toolbox”.

Installation

You can install the released version from CRAN with:

install.packages("waterquality")

You can install waterquality from github with:

# install.packages("devtools")
devtools::install_github("RAJohansen/waterquality")

Basic Example

The main function in this package is wq_calc():

library(waterquality)
library(terra)
s2 = terra::rast(system.file("raster/S2_Harsha.tif", package = "waterquality"))
MM12NDCI = wq_calc(s2, alg = "MM12NDCI", sat = "sentinel2")
Map_WQ_raster(WQ_raster = MM12NDCI,
              map_title= "Water Quality Map",
              raster_style = "quantile",
              histogram = TRUE)
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#>      (status 2 uses the sf package in place of rgdal)

Citation

To cite waterquality in publications, please use:

Johansen R, Nowosad J, Reif M, Emery E (2023). waterquality: Satellite Derived Water Quality Detection Algorithms. U.S Army Engineer Research and Development Center, Vicksburg, MS, USA. R package version 1.0.0, https://github.com/RAJohansen/waterquality/.

Package Contributions

We encourage users to submit issues and enhancement requests so we may continue to improve our package.

Furthermore, if you have a water quality algorithm that was not on our list, and you would like for it to be included in our package please email Richard.A.Johansen@erdc.dren.mil.

Copy Link

Version

Install

install.packages('waterquality')

Monthly Downloads

192

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Richard Johansen

Last Published

August 7th, 2023

Functions in waterquality (1.0.0)

Be16FLHBlueRedNIR_LS8

Be16FLHBlueRedNIR_LS8 algorithm
Am09KBBI

Am09KBBI algorithm
Be16FLHBlueRedNIR_OLCI

Be16FLHBlueRedNIR_OLCI algorithm
Al10SABI

Al10SABI algorithm
Be162BsubPhy

Be162BsubPhy algorithm
Be162B700sub601

Be162B700sub601 algorithm
Be162B643sub629

Be162B643sub629 algorithm
Be16FLHBlueRedNIR_S2

Be16FLHBlueRedNIR_S2 algorithm
Be16FLHGreenRedNIR_OLCI

Be16FLHGreenRedNIR_OLCI algorithm
Be16FLHGreenRedNIR_S2

Be16FLHGreenRedNIR_S2 algorithm
Be16FLHGreenRedNIR_MERIS

Be16FLHGreenRedNIR_MERIS algorithm
Be16FLHGreenRedNIR_WV2

Be16FLHGreenRedNIR_WV2 algorithm
Be16FLHVioletRedNIR_LS8

Be16FLHVioletRedNIR_LS8 algorithm
Be16FLHVioletRedNIR_OLCI

Be16FLHVioletRedNIR_OLCI algorithm
Be16FLHGreenRedNIR_LS8

Be16FLHGreenRedNIR_LS8 algorithm
Be16FLHVioletRedNIR_S2

Be16FLHVioletRedNIR_S2 algorithm
Be16FLHVioletRedNIR_MERIS

Be16FLHVioletRedNIR_MERIS algorithm
Be16FLHBlueRedNIR_WV2

Be16FLHBlueRedNIR_WV2 algorithm
Be16FLHblue_S2

Be16FLHblue_S2 algorithm
Be16FLHviolet_OLCI

Be16FLHviolet_OLCI algorithm
Be16FLHblue_WV2

Be16FLHblue_WV2 algorithm
Be16FLHblue_MERIS

Be16FLHblue_MERIS algorithm
Be16FLHVioletRedNIR_WV2

Be16FLHVioletRedNIR_WV2 algorithm
Be16FLHblue_LS8

Be16FLHblue_LS8 algorithm
Be16FLHviolet_S2

Be16FLHviolet_S2 algorithm
Be16FLHviolet_LS8

Be16FLHviolet_LS8 algorithm
Be16FLHviolet_MERIS

Be16FLHviolet_MERIS algorithm
Be16FLHblue_OLCI

Be16FLHblue_OLCI algorithm
Be16Phy2BDA644over629

Be16Phy2BDA644over629 algorithm
Be16NDTIviolet

Be16NDTIviolet algorithm
De933BDA

De933BDA algorithm
Be16FLHviolet_WV2

Be16FLHviolet_WV2 algorithm
Gi033BDA

Gi033BDA algorithm
Be16NDTIblue

Be16NDTIblue algorithm
Be16NDPhyI644over629

Be16NDPhyI644over629 algorithm
Be16NDPhyI

Be16NDPhyI algorithm
Da052BDA

Da052BDA algorithm
Be16NDPhyI644over615

Be16NDPhyI644over615 algorithm
Kn07KIVU

Kn07KIVU algorithm
MI092BDA

MI092BDA algorithm
MM092BDA

MM092BDA algorithm
MM12NDCI

MM12NDCI algorithm
Map_WQ_raster

Create waterquality Map with sampling points and optional histogram
SI052BDA

SI052BDA algorithm
HU103BDA

HU103BDA algorithm
Go04MCI

Go04MCI algorithm
MM12NDCIalt

MM12NDCIalt algorithm
MM143BDAopt

MM143BDAopt algorithm
TurbDox02NIRoverRed

TurbDox02NIRoverRed algorithm
TurbFrohn09GreenPlusRedBothOverBlue

TurbFrohn09GreenPlusRedBothOverBlue algorithm
SY002BDA

SY002BDA algorithm
SM122BDA

SM122BDA algorithm
TurbBe16RedOverViolet

TurbBe16RedOverViolet algorithm
TurbBe16GreenPlusRedBothOverViolet

TurbBe16GreenPlusRedBothOverViolet algorithm
TurbBow06RedOverGreen

TurbBow06RedOverGreen algorithm
TurbHarr92NIR

TurbHarr92NIR algorithm
TurbChip09NIROverGreen

TurbChip09NIROverGreen algorithm
wq_algorithms

wq_algorithms database
extract_lm_cv_multi

Run linear model with crossvalidation over multiple independent and dependent variables
extract_lm

Run linear model (lm)
TurbLath91RedOverBlue

TurbLath91RedOverBlue algorithm
extract_lm_cv

Run linear model with crossvalidation
wq_calc

Water quality calculation
extract_lm_cv_all

Run linear model with crossvalidation over multiple dependent and all numeric independent variables in a data frame
TurbMoore80Red

TurbMoore80Red algorithm
waterquality-package

waterquality: Satellite Derived Water Quality Detection Algorithms
Wy08CI

Wy08CI algorithm
%>%

Pipe operator
Be16FLHBlueRedNIR_MERIS

Be16FLHBlueRedNIR_MERIS algorithm
Am092Bsub

Am092Bsub algorithm