calc_ndwi: Calculate Normalized Difference Water Index (NDWI)

View source: R/calc_indices.R

calc_ndwiR Documentation

Calculate Normalized Difference Water Index (NDWI)

Description

Computes McFeeters' Normalized Difference Water Index (NDWI) for delineating open water bodies.

Usage

calc_ndwi(green, nir)

Arguments

green

Green band (terra::SpatRaster or numeric).

nir

Near-infrared band (terra::SpatRaster or numeric).

Details

NDWI = \frac{GREEN - NIR}{GREEN + NIR}

Description & Purpose: NDWI maximizes the reflectance of water in the green wavelength while minimizing the low reflectance of water in the NIR wavelength.

Interpretation:

  • > 0.0: Water surfaces (rivers, lakes, wetlands, reservoirs).

  • <= 0.0: Non-water surfaces (vegetation, soil, built-up areas).

Value

A terra::SpatRaster (named "NDWI") or numeric vector with index values.

References

McFeeters, S. K. (1996). The use of the Normalized Difference Water Index (NDWI) in the delineation of open water features. International Journal of Remote Sensing, 17(7), 1425-1432.

See Also

calc_mndwi, calc_awei, geo_index

Examples

calc_ndwi(green = 0.6, nir = 0.2)

img <- get_example_data()
ndwi_rast <- calc_ndwi(green = img[["green"]], nir = img[["nir"]])
print(ndwi_rast)


GeoIndexR documentation built on Oct. 10, 2026, 5:08 p.m.