[GRASS-SVN] r67654 - grass-addons/grass7/imagery/i.wi

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 24 13:48:20 PST 2016


Author: ychemin
Date: 2016-01-24 13:48:20 -0800 (Sun, 24 Jan 2016)
New Revision: 67654

Added:
   grass-addons/grass7/imagery/i.wi/ndwi.c
Log:
added ndwi library with 2 versions

Added: grass-addons/grass7/imagery/i.wi/ndwi.c
===================================================================
--- grass-addons/grass7/imagery/i.wi/ndwi.c	                        (rev 0)
+++ grass-addons/grass7/imagery/i.wi/ndwi.c	2016-01-24 21:48:20 UTC (rev 67654)
@@ -0,0 +1,42 @@
+#include<stdio.h>
+#include<math.h>
+#include<stdlib.h>
+
+    /* Normalized Difference Water Index (NDWI McFeeters)
+     * 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,
+1425–1432. http://dx.doi.org/10.1080/01431169608948714.
+     * Landsat TM/ETM+ : (b2-b4)/(b2+b4) (green-NIR)/(green+NIR)
+     */ 
+double ndwi_mcfeeters(double greenchan, double nirchan) 
+{
+    double result;
+
+    if ((greenchan + nirchan) == 0.0) {
+	result = -1.0;
+    }
+    else {
+	result = (greenchan - nirchan) / (greenchan + nirchan);
+    }
+    return result;
+}
+
+    /* Normalized Difference Water Index (NDWI Xu)
+     * 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, 3025–3033. http://dx.doi.org/10.1080/01431160600589179.
+     * Landsat TM/ETM+ : (b2-b5)/(b2+b5) (green-MIR)/(green+MIR)
+     */ 
+double ndwi_xu(double greenchan, double mirchan) 
+{
+    double result;
+
+    if ((greenchan + mirchan) == 0.0) {
+	result = -1.0;
+    }
+    else {
+	result = (greenchan - mirchan) / (greenchan + mirchan);
+    }
+    return result;
+}
+



More information about the grass-commit mailing list