-
Notifications
You must be signed in to change notification settings - Fork 85
Description
Reason or Problem
The multispectral module has 11 spectral indices for vegetation, burn severity, and moisture, but nothing for water. NDWI (McFeeters 1996) and MNDWI (Xu 2006) are the standard indices for mapping surface water, wetlands, and flood extent. Right now, analysts have to write their own band math to detect water bodies.
Proposal
Design:
Add two functions to xrspatial/multispectral.py, following the same pattern as NDVI, NDMI, etc.:
ndwi(green, nir)--(Green - NIR) / (Green + NIR)(McFeeters 1996)mndwi(green, swir)--(Green - SWIR) / (Green + SWIR)(Xu 2006)
Both are normalized difference formulas, so the implementation reuses _normalized_ratio_worker. All four backends (NumPy, Dask, CuPy, Dask+CuPy) work automatically.
Usage:
from xrspatial import ndwi, mndwi
water_mask = ndwi(green_band, nir_band)
urban_water = mndwi(green_band, swir_band)
# or via accessor
water = green_band.xrs.ndwi(nir_band)Value:
Water body mapping comes up constantly in flood monitoring, wetland inventory, and land cover classification. Having NDWI and MNDWI alongside the existing vegetation indices means analysts don't need to drop out of xarray-spatial for this.
Stakeholders and Impacts
Remote sensing analysts, flood/water resource scientists, land cover mappers. No impact on existing functions; purely additive.
Drawbacks
Low. These are normalized differences identical in form to NDVI, so there's not much new code to maintain.
Alternatives
- Write
(green - nir) / (green + nir)inline. Works, but skips input validation, NaN handling, and multi-backend dispatch. - rasterio/GDAL band math. Requires C dependencies.
Unresolved Questions
- Whether to also add AWEI (Automated Water Extraction Index, Feyisa et al. 2014), which uses 5 bands. Probably better as a follow-up.