[GRASS-SVN] r69035 - grass/branches/releasebranch_7_0/imagery/i.vi

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jul 24 16:40:29 PDT 2016


Author: neteler
Date: 2016-07-24 16:40:29 -0700 (Sun, 24 Jul 2016)
New Revision: 69035

Modified:
   grass/branches/releasebranch_7_0/imagery/i.vi/main.c
Log:
i.vi: print msg which index is actually calculated; fix ARVI name; apply standard NDVI color table in case of viname=ndvi (trunk, r68692)

Modified: grass/branches/releasebranch_7_0/imagery/i.vi/main.c
===================================================================
--- grass/branches/releasebranch_7_0/imagery/i.vi/main.c	2016-07-24 23:37:59 UTC (rev 69034)
+++ grass/branches/releasebranch_7_0/imagery/i.vi/main.c	2016-07-24 23:40:29 UTC (rev 69035)
@@ -112,7 +112,7 @@
     G_asprintf(&desc,
 	       "arvi;%s;dvi;%s;evi;%s;evi2;%s;gvi;%s;gari;%s;gemi;%s;ipvi;%s;msavi;%s;"
 	       "msavi2;%s;ndvi;%s;pvi;%s;savi;%s;sr;%s;vari;%s;wdvi;%s",
-	       _("Atmospherically Resistant Vegetation Indices"),
+	       _("Atmospherically Resistant Vegetation Index"),
 	       _("Difference Vegetation Index"),
 	       _("Enhanced Vegetation Index"),
 	       _("Enhanced Vegetation Index 2"),
@@ -222,6 +222,7 @@
     if(opt.bits->answer)
         dnbits = atof(opt.bits->answer);
     result = opt.output->answer;
+    G_message(_("Calculating %s"), viflag);
 
     if (!strcasecmp(viflag, "sr") && (!(opt.red->answer) || !(opt.nir->answer)) )
 	G_fatal_error(_("sr index requires red and nir maps"));
@@ -534,11 +535,20 @@
     G_free(outrast);
     Rast_close(outfd);
 
-    /* Color from -1.0 to +1.0 in grey */
-    Rast_init_colors(&colors);
-    val1 = -1;
-    val2 = 1;
-    Rast_add_c_color_rule(&val1, 0, 0, 0, &val2, 255, 255, 255, &colors);
+    if (!strcasecmp(viflag, "ndvi")) {
+ 	/* apply predefined NDVI color table */
+	const char *style = "ndvi";
+	if (G_find_color_rule("ndvi")) {
+	   Rast_make_fp_colors(&colors, style, -1.0, 1.0);
+	} else
+	   G_fatal_error(_("Unknown color request '%s'"), style);
+    } else {
+	/* Color from -1.0 to +1.0 in grey */
+	Rast_init_colors(&colors);
+	val1 = -1;
+	val2 = 1;
+	Rast_add_c_color_rule(&val1, 0, 0, 0, &val2, 255, 255, 255, &colors);
+    }
     Rast_write_colors(result, G_mapset(), &colors);
 
     Rast_short_history(result, "raster", &history);



More information about the grass-commit mailing list