[GRASS-SVN] r68696 - grass/branches/releasebranch_7_2/imagery/i.vi

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 15 11:47:40 PDT 2016


Author: neteler
Date: 2016-06-15 11:47:40 -0700 (Wed, 15 Jun 2016)
New Revision: 68696

Modified:
   grass/branches/releasebranch_7_2/imagery/i.vi/main.c
Log:
i.vi: apply standard NDVI color table in case of viname=ndvi (trunk, r68692)

Modified: grass/branches/releasebranch_7_2/imagery/i.vi/main.c
===================================================================
--- grass/branches/releasebranch_7_2/imagery/i.vi/main.c	2016-06-15 16:51:56 UTC (rev 68695)
+++ grass/branches/releasebranch_7_2/imagery/i.vi/main.c	2016-06-15 18:47:40 UTC (rev 68696)
@@ -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