[GRASSLIST:2442] Re: Applying ranges of color to a raster map

Hamish hamish_nospam at yahoo.com
Tue Feb 3 00:56:22 EST 2004


> How can I apply ranges of color to a raster map?
> 
> I want to specify ranges of color, like the pre-defined ones that 
> r.colors uses (such as byr)  Applying byr to a map gives a gradient of
> 
> blue through yellow to red.  But I want to specify where the break 
> points occur.  I can't use percentages in a user defined file because 
> then r.colors decides based on the total RANGE of colors.  I have a
> set of maps (RADAR) where the total range of values varies from image
> to image, but each value must be colored the same way across maps (so
> they look right in a sequence animation).  I can't edit the color file
> 
> manually, because I am trying to automate the processing of thousands 
> of files.


Create a custom color table with r.colors for a representative map (full
range of values), then copy that color map to each subsequent map.

The values you enter into r.colors are absolute, not percentages (unless
you use the % sign).

e.g.

r.colors map=radar_map001 color=rules << EOF
0   black
250  blue
500  yellow
750  red
1000 white
EOF

...

r.colors map=radar_map002 rast=radar_map001
r.colors map=radar_map003 rast=radar_map001

...


If you want to use d.legend in the animation, GRASS 5.3+ supports using 
the range= option to draw to the extent of the color table, not just 
the range of values shown on the map which is the default. Of course
you'd have to use the at= option to draw it in the same place for each
frame.


Have a look at the 'gifsicle' program for creating animated GIFs you can
play back in any web browser, esp. nice in a web browser that does full
screen mode..
http://www.lcdf.org/~eddietwo/gifsicle/



good luck,
Hamish




More information about the grass-user mailing list