[GRASS-SVN] r68692 - grass/trunk/imagery/i.vi

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 14 14:29:15 PDT 2016


Author: neteler
Date: 2016-06-14 14:29:15 -0700 (Tue, 14 Jun 2016)
New Revision: 68692

Modified:
   grass/trunk/imagery/i.vi/main.c
Log:
i.vi: apply standard NDVI color table in case of viname=ndvi

Modified: grass/trunk/imagery/i.vi/main.c
===================================================================
--- grass/trunk/imagery/i.vi/main.c	2016-06-14 21:28:07 UTC (rev 68691)
+++ grass/trunk/imagery/i.vi/main.c	2016-06-14 21:29:15 UTC (rev 68692)
@@ -534,11 +534,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