CRAN status Build Status codecov downloads


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 45 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”.


You can install the released version from CRAN with:


You can install waterquality from github with:

# install.packages("devtools")

Basic Example

The main function in this package is wq_calc():

s2 = stack(system.file("raster/S2_Harsha.tif", package = "waterquality"))
s2_two_alg = wq_calc(s2, alg = c("TurbChip09NIROverGreen", "Be16FLHGreenRedNIR"), sat = "sentinel2")

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