[GRASS-user] Need for a custom color map

Hamish hamish_nospam at yahoo.com
Sun Oct 21 00:31:37 EDT 2007


Thomas Adams wrote:
> I'm wondering if someone has a color map that has white in the middle 
> range and blue at one extreme and red at the other. I'm creating a 
> precipitation difference map for data quality control purposes and I'm 
> trying to identify areas of over- and under-estimation by radar 
> estimates relative to gauge-only estimates. Such a scale would be 
> helpful to those looking for differences.

Glynn wrote:
> The "differences" map (i.e. "r.colors ... color=differences") is:
> 	0% blue
> 	0 white
> 	100% red
> 
> This may be suitable, depending upon what you mean by "white in the
> middle". The above has white at zero, which isn't necessarily the
> middle. If you want white at the midpoint between the minimum and
> maximum values, use:
> 	0% blue
> 	50% white
> 	100% red
> 
> If you want the table to be symmetrical, you'll need to specify
> absolute values rather than percentages, e.g.:
> 	-10 blue
> 	0 white
> 	10 red


Doing a symmetrical absolute value color maps interests me, so I wrote a script to do it automatically based on r.univar results. It's called r.colors.stddev and it is now u on the wiki addons page. Read all about it & screenshots here:
  http://hamish.bowman.googlepages.com/grass_color_maps

I am not a statistician, so take my approach with a grain of salt and improvements are welcome. -- The book "How to lie with statistics" could easily have a second edition "How to lie with the human eye and color rules".


One problem that came up, the r.univar percentile= option only takes integer values. You can pass it a FP number but it just chops off everything after the decimal point. (I wanted the percentile values for 68.2689%, 95.4500%, 99.7300% of area under the curve, right now r.univar casts those to int so results are not exactly right) I have patched it locally (int->double, %d->%lf,%g), but it causes a few little problems:

1) cosmetic: there are rules for the 1st 2nd 3rd 4-9,0th percentile text.
It would need to be updated to use the least significant digit from %g.
Also that has i18n concerns...

2) the percentile shell script output would get a "." in it, which is invalid for an environment variable $name. It could be replaced with an underscore, ....?

3) It gives an answer, but is it an appropriate/meaningful thing to calculate?
(tiny doubt lingers)


enjoy,
Hamish




More information about the grass-user mailing list