[GRASS-user] set color for negative and positive values

Tim Holland timothyholland at gmail.com
Sun Sep 6 02:59:26 EDT 2009




Milton Cezar Ribeiro wrote:
> 
> 
> I have a set of 10,000 distance maps. On this map I have
> negative (-300 to 0) and posivie (0 to +300) values.
> I would like to attrib a color table to those maps
> from yellow-cyan-dark green when the negative values
> goes from 0 to -300, and from yellow-orange-red
> when values goes from 0 to +300
> 
> 
> 


Hi, 

I'm not sure if you have raster maps or vector, but I think the answer will
be similar either way.  With raster, you can use r.colors to set the color
table of the map (with vector, I think v.colors works in a similar way).  In
r.colors, you can specify a rules file for the colors.  The format of the
rules file is quite flexible, you can set the values for particular colors
either as absolute values (e.g. -300 or +300) or as percentages defined
based on the whole range of values (e.g. 0% or 100%).  Colors can also be
specified using either common color names ("red") or rgb triplets (255 0 0). 
As far as I can tell, you can mix and match formats at will.  r.colors
manual will give more info.  

I was doing something very similar recently (having opposing scales for
negative and positive values, with white representing 0).  The code I used
was

>r.colors map=$rast
rules=/usr/color_tables/TreeCoverChange_RedWhiteGreen.file

With the rules file being a text file containing the following: 

0% 255 0 0
-0.5 255 240 180
0 white
0.5 180 230 130
100% 0 70 0

Those aren't the colors you want (mine was red for negatives, green for
positives, but that's the idea).  You would do something like the following

0% (whatever the RGB values for dark green are)
0 (whatever the RGB values for yellow are)
100% red

Also, I had a problem with color tables set for negative values when I was
displaying data through the plugin in QGIS.  I never figured that out except
by manually setting the colors in QGIS itself.  But as long as I was
displaying in GRASS directly (using the PNG driver and d.rast), r.colors
worked fine.  

HTH
Tim
-- 
View this message in context: http://n2.nabble.com/set-color-for-negative-and-positive-values-tp3591519p3591660.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list