xrspatial.multispectral.mndwi#
- xrspatial.multispectral.mndwi(green_agg: DataArray, swir_agg: DataArray, name='mndwi')[source]#
Computes Modified Normalized Difference Water Index (MNDWI).
MNDWI improves on NDWI for urban areas by substituting SWIR for NIR, which reduces false positives from built-up surfaces.
- Parameters:
green_agg (xr.DataArray) – 2D array of green band data. (Landsat 8: Band 3) (Sentinel-2: Band 3)
swir_agg (xr.DataArray) – 2D array of shortwave infrared band data. (Landsat 8: Band 6) (Sentinel-2: Band 11)
name (str, default='mndwi') – Name of output DataArray.
Alternatively
first (a single xr.Dataset may be passed as the)
Dataset (argument with keyword arguments mapping band names to)
example:: (variables. For) – mndwi(ds, green=’B3’, swir=’B11’)
- Returns:
mndwi_agg – 2D array of mndwi values in the range [-1, 1]. All other input attributes are preserved.
- Return type:
xr.DataArray of same type as inputs
References
Xu, H., 2006. Modification of normalised difference water index (NDWI) to enhance open water features in remotely sensed imagery. International Journal of Remote Sensing, 27(14), pp.3025-3033.
Examples
>>> import numpy as np >>> import xarray as xr >>> from xrspatial.multispectral import mndwi >>> green = xr.DataArray(np.array([[600., 500.], [400., 300.]])) >>> swir = xr.DataArray(np.array([[300., 400.], [500., 600.]])) >>> mndwi(green, swir).values array([[ 0.33333334, 0.11111111], [-0.11111111, -0.33333334]], dtype=float32)