Browse Source

Added Crust Index algorithm to i.vi (#1997)

As per Request #1995 : https://github.com/OSGeo/grass/issues/1995
Yann Chemin 3 years ago
parent
commit
6fb6afdd94
3 changed files with 52 additions and 3 deletions
  1. 23 0
      imagery/i.vi/ci.c
  2. 18 1
      imagery/i.vi/i.vi.html
  3. 11 2
      imagery/i.vi/main.c

+ 23 - 0
imagery/i.vi/ci.c

@@ -0,0 +1,23 @@
+#include<stdio.h>
+#include<math.h>
+#include<stdlib.h>
+
+/*From https://karnieli-rsl.com/image.ashx?i=901711.pdf&fn=1997-Karnieli_CI_IJRS_97.pdf
+ * Crust Index CI=1-(RED-BLUE)/(RED+BLUE). (KARNIELI, 1997)
+ * Development and implementation of spectral crust index over dune sands
+ * The Remote Sensing Laboratory, J. Blaustein Institute for Desert Research, Ben Gurion University, Sede-Boker Campus 84990, Israel. (Received 26 January 1996; in ® nal form 19 July 1996) */
+    /* Crust Index */ 
+double c_i(double bluechan, double redchan) 
+{
+    double result;
+
+    if ((redchan + bluechan) == 0.0) {
+	result = -1.0;
+    }
+    else {
+	result = 1 - (redchan - bluechan) / (redchan + bluechan);
+    }
+    return result;
+}
+
+

+ 18 - 1
imagery/i.vi/i.vi.html

@@ -4,7 +4,8 @@
 parameters.
 
 <ul>
-  <li>ARVI: atmospherically resistant vegetation indices</li>
+  <li>ARVI: Atmospherically Resistant Vegetation Index</li>
+  <li>CI: Crust Index</li>
   <li>DVI: Difference Vegetation Index</li>
   <li>EVI: Enhanced Vegetation Index</li>
   <li>EVI2: Enhanced Vegetation Index 2</li>
@@ -79,6 +80,22 @@ ARVI = (nirchan - (2.0*redchan - bluechan)) /
        ( nirchan + (2.0*redchan - bluechan))
 </pre></div>
 
+<b>CI: Crust Index</b> 
+<p>
+Advantage is taken of a unique spectral feature of soil biogenic
+crust containing cyanobacteria. It has been shown that the special phycobilin
+pigment in cyanobacteria contributes in producing a relatively higher re ̄ ectance
+in the blue spectral region than the same type of substrate without the
+biogenic crust. The spectral crust index (CI) is based on
+the normalized difference between the RED and the BLUE spectral values (Karnieli, 1997).
+
+<div class="code"><pre>
+ci ( bluechan, redchan )
+
+CI = 1 - (redchan - bluechan) / 
+       (redchan + bluechan)
+</pre></div>
+
 <p>
 <b>DVI: Difference Vegetation Index</b>
 

+ 11 - 2
imagery/i.vi/main.c

@@ -36,6 +36,7 @@
 #include <grass/raster.h>
 #include <grass/glocale.h>
 
+double c_i(double bluechan, double redchan); 
 double s_r(double redchan, double nirchan);
 double nd_vi(double redchan, double nirchan);
 double nd_wi(double greenchan, double nirchan);
@@ -107,9 +108,10 @@ int main(int argc, char *argv[])
     opt.viname->description = _("Type of vegetation index");
     desc = NULL;
     G_asprintf(&desc,
-	       "arvi;%s;dvi;%s;evi;%s;evi2;%s;gvi;%s;gari;%s;gemi;%s;ipvi;%s;msavi;%s;"
+	       "arvi;%s;ci;%s;dvi;%s;evi;%s;evi2;%s;gvi;%s;gari;%s;gemi;%s;ipvi;%s;msavi;%s;"
 	       "msavi2;%s;ndvi;%s;ndwi;%s;pvi;%s;savi;%s;sr;%s;vari;%s;wdvi;%s",
 	       _("Atmospherically Resistant Vegetation Index"),
+	       _("Crust Index"),
 	       _("Difference Vegetation Index"),
 	       _("Enhanced Vegetation Index"),
 	       _("Enhanced Vegetation Index 2"),
@@ -127,7 +129,7 @@ int main(int argc, char *argv[])
 	       _("Visible Atmospherically Resistant Index"),
 	       _("Weighted Difference Vegetation Index"));
     opt.viname->descriptions = desc;
-    opt.viname->options = "arvi,dvi,evi,evi2,gvi,gari,gemi,ipvi,msavi,msavi2,ndvi,ndwi,pvi,savi,sr,vari,wdvi";
+    opt.viname->options = "arvi,ci,dvi,evi,evi2,gvi,gari,gemi,ipvi,msavi,msavi2,ndvi,ndwi,pvi,savi,sr,vari,wdvi";
     opt.viname->answer = "ndvi";
     opt.viname->key_desc = _("type");
 
@@ -232,6 +234,9 @@ int main(int argc, char *argv[])
     result = opt.output->answer;
     G_verbose_message(_("Calculating %s..."), viflag);
 
+    if (!strcasecmp(viflag, "ci") && (!(opt.blue->answer) || !(opt.red->answer)) )
+	G_fatal_error(_("ci index requires blue and red maps"));
+
     if (!strcasecmp(viflag, "sr") && (!(opt.red->answer) || !(opt.nir->answer)) )
 	G_fatal_error(_("sr index requires red and nir maps"));
 
@@ -468,6 +473,10 @@ int main(int argc, char *argv[])
 		Rast_set_f_null_value(&outrast[col], 1);
 	    }
 	    else {
+		/* calculate crust_index        */
+		if (!strcasecmp(viflag, "ci"))
+		    outrast[col] = c_i(d_bluechan, d_redchan);
+
 		/* calculate simple_ratio        */
 		if (!strcasecmp(viflag, "sr"))
 		    outrast[col] = s_r(d_redchan, d_nirchan);