[GRASS-user] Help using color tables (differences)

List:

I have been using r.colors -n map=mapname color=differences to display soil moisture differences from one day to another (to identify areas that have received precipitation and areas that are drying); I would like to depict wetting areas as shades of blue to white and drying areas as shades of white to red — as the the option color=differences tries to do. The difficulty I'm running into is that unless there is a fairly even proportion of of positive & negative values I'll have wetting areas colored a shade of red instead of blue, but more often, the reverse where drying areas are colored blue, due to the shift of the color scale. Ideally, I want values close to -0- to be white and wet areas to be a shade of blue and dry areas to be a shade of red. How can I do this? Any suggestions?

Thanks,
Tom

--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL: thomas.adams@noaa.gov

VOICE: 937-383-0528
FAX: 937-383-0033

Hi Thomas,

I have been using r.colors -n map=mapname color=differences
to display soil moisture differences from one day to another
(to identify areas that have received precipitation and
areas that are drying); I would like to depict wetting areas
as shades of blue to white and drying areas as shades of
white to red — as the the option color=differences tries
to do. The difficulty I'm running into is that unless there
is a fairly even proportion of of positive & negative
values I'll have wetting areas colored a shade of red
instead of blue, but more often, the reverse where drying
areas are colored blue, due to the shift of the color scale.
Ideally, I want values close to -0- to be white and wet
areas to be a shade of blue and dry areas to be a shade of
red. How can I do this? Any suggestions?

try the 'r.colors.stdev -z' which was recently moved into the
main source tree from the addons repository. maybe a new option
could be added to do a better differences map.

some examples here:
  http://hamish.bowman.googlepages.com/grass_color_maps

for the color rules $GISBASE/etc/differences does:
0% blue
0 white
100% red

what you really want is to have it evenly scaled like:

peak = the greater of abs($min) and abs($max)
-$peak blue
0 white
$peak red

you could use awk to do that a>b logic in a script if you needed
to.

then use those rules as custom color rules with r.colors.

or for you entire dataset decide some static rules, then inter-
map differences are comparable on the same visual scale.

Hamish

Hamish,

Thank you! I think your suggestion will work for me; I'll let you know…

Cheers!
Tom

----- Original Message -----
From: Hamish <hamish_b@yahoo.com>
Date: Friday, August 7, 2009 6:39 pm
Subject: Re: [GRASS-user] Help using color tables (differences)

Hi Thomas,
> I have been using r.colors -n map=mapname color=differences
> to display soil moisture differences from one day to another
> (to identify areas that have received precipitation and
> areas that are drying); I would like to depict wetting areas
> as shades of blue to white and drying areas as shades of
> white to red — as the the option color=differences tries
> to do. The difficulty I'm running into is that unless there
> is a fairly even proportion of of positive & negative
> values I'll have wetting areas colored a shade of red
> instead of blue, but more often, the reverse where drying
> areas are colored blue, due to the shift of the color scale.
> Ideally, I want values close to -0- to be white and wet
> areas to be a shade of blue and dry areas to be a shade of
> red. How can I do this? Any suggestions?

try the 'r.colors.stdev -z' which was recently moved into the
main source tree from the addons repository. maybe a new option
could be added to do a better differences map.

some examples here:
http://hamish.bowman.googlepages.com/grass_color_maps

for the color rules $GISBASE/etc/differences does:
0% blue
0 white
100% red

what you really want is to have it evenly scaled like:

peak = the greater of abs($min) and abs($max)
-$peak blue
0 white
$peak red

you could use awk to do that a>b logic in a script if you needed
to.

then use those rules as custom color rules with r.colors.

or for you entire dataset decide some static rules, then inter-
map differences are comparable on the same visual scale.

Hamish

Hamish,

I just tried using r.colors.stdev -z — I guess I incorrectly *assumed* it would not do what I wanted. It looks like it does what I want except for the option to invert the colors. So, adding the 'Invert' option would be great.

Regards,
Tom

----- Original Message -----
From: Hamish <hamish_b@yahoo.com>
Date: Friday, August 7, 2009 6:39 pm
Subject: Re: [GRASS-user] Help using color tables (differences)

Hi Thomas,
> I have been using r.colors -n map=mapname color=differences
> to display soil moisture differences from one day to another
> (to identify areas that have received precipitation and
> areas that are drying); I would like to depict wetting areas
> as shades of blue to white and drying areas as shades of
> white to red — as the the option color=differences tries
> to do. The difficulty I'm running into is that unless there
> is a fairly even proportion of of positive & negative
> values I'll have wetting areas colored a shade of red
> instead of blue, but more often, the reverse where drying
> areas are colored blue, due to the shift of the color scale.
> Ideally, I want values close to -0- to be white and wet
> areas to be a shade of blue and dry areas to be a shade of
> red. How can I do this? Any suggestions?

try the 'r.colors.stdev -z' which was recently moved into the
main source tree from the addons repository. maybe a new option
could be added to do a better differences map.

some examples here:
http://hamish.bowman.googlepages.com/grass_color_maps

for the color rules $GISBASE/etc/differences does:
0% blue
0 white
100% red

what you really want is to have it evenly scaled like:

peak = the greater of abs($min) and abs($max)
-$peak blue
0 white
$peak red

you could use awk to do that a>b logic in a script if you needed
to.

then use those rules as custom color rules with r.colors.

or for you entire dataset decide some static rules, then inter-
map differences are comparable on the same visual scale.

Hamish

On Sat, 2009-08-08 at 15:35 -0400, Thomas.Adams@noaa.gov wrote:

Hamish,

I just tried using r.colors.stdev -z — I guess I incorrectly *assumed* it would not do what I wanted. It looks like it does what I want except for the option to invert the colors. So, adding the 'Invert' option would be great.

Regards,
Tom

Perhaps a (very) stupid (attempt to) work-around for the time being:
"r.colors -n rast=..." on a map already colored based on "r.colors.stdev
-z" :-?

Nikos

----- Original Message -----
From: Hamish <hamish_b@yahoo.com>
Date: Friday, August 7, 2009 6:39 pm
Subject: Re: [GRASS-user] Help using color tables (differences)

> Hi Thomas,
> > I have been using r.colors -n map=mapname color=differences
> > to display soil moisture differences from one day to another
> > (to identify areas that have received precipitation and
> > areas that are drying); I would like to depict wetting areas
> > as shades of blue to white and drying areas as shades of
> > white to red — as the the option color=differences tries
> > to do. The difficulty I'm running into is that unless there
> > is a fairly even proportion of of positive & negative
> > values I'll have wetting areas colored a shade of red
> > instead of blue, but more often, the reverse where drying
> > areas are colored blue, due to the shift of the color scale.
> > Ideally, I want values close to -0- to be white and wet
> > areas to be a shade of blue and dry areas to be a shade of
> > red. How can I do this? Any suggestions?
>
> try the 'r.colors.stdev -z' which was recently moved into the
> main source tree from the addons repository. maybe a new option
> could be added to do a better differences map.
>
> some examples here:
> http://hamish.bowman.googlepages.com/grass_color_maps
>
>
> for the color rules $GISBASE/etc/differences does:
> 0% blue
> 0 white
> 100% red
>
> what you really want is to have it evenly scaled like:
>
> peak = the greater of abs($min) and abs($max)
> -$peak blue
> 0 white
> $peak red
>
>
> you could use awk to do that a>b logic in a script if you needed
> to.
>
> then use those rules as custom color rules with r.colors.
>
> or for you entire dataset decide some static rules, then inter-
> map differences are comparable on the same visual scale.
>
>
> Hamish
>
>
>
>
>
>
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Tom wrote:

> I just tried using r.colors.stdev -z — I guess I incorrectly
*assumed* it would not do what I wanted. It looks like it does
what I want except for the option to invert the colors. So,
adding the 'Invert' option would be great.

if you don't mind such things it's trivial to open the script up
in a text editor and add the -n flag, or change red<->blue.

Nikos wrote:

Perhaps a (very) stupid (attempt to) work-around for the time being:
"r.colors -n rast=..." on a map already colored based
on "r.colors.stdev -z" :-?

in fact very smart -- it works well:

#spearfish
g.region rast=elevation.dem
eval `r.univar -g elevation.dem`
r.mapcalc "elev.diff = elevation.dem - $mean"
r.colors.stddev -z elev.diff
d.mon x0
d.rast elev.diff

# flip current color rules:
r.colors -n elev.diff rast=elev.diff
d.rast elev.diff

Hamish