[GRASS-user] create a common colour scale

Hamish hamish.webmail at gmail.com
Mon Jul 28 21:52:39 PDT 2014


Raphael wrote:
> I wonder if anyone knows how to create a common colour scale for
> different raster maps? I want to display all six maps on the same
> page with the single colour scale but I cannot find how to do this in
> GRASS.
> 
> More specifically, I have six raster maps of rainfall for different
> time periods (each has a different range of values) and I would like
> to display them all with the same colour scale. The colour scale
> needs to be constructed using the min and max values of the set of
> six maps (and not just individual maps.


For only 6 maps I wouldn't bother with scripting a mix,max variable,
just run r.info in a loop and copy out the min,max by hand.

for MAP in `g.mlist rast pattern=rain*` ; do
   r.info -r $MAP
done

then make a dummy map with r.mapcalc with overall min and max range.

min=1.2345
max=9.8765
r.mapcalc "color_map = if(row < 10, $min, $max)"

and then apply it with:

for MAP in `g.mlist rast pattern=rain*` ; do
   r.colors $MAP rast=color_map
done

Or run r.colors with the rules= option to set up some color rules
by hand, then apply to all in a loop.


But what I usually do these days in GRASS 6 is to use the r.stack
addon module to temporarily consider all the maps together, which
allows for the nice 'r.colors -e' equalized histogram color scaling.
You can copy the color map to a small dummy raster with the r.colors
rast= option then delete the stacked raster map if you want to save
space, then apply it to all maps as in the Bourne shell loop above.


regards,
Hamish


More information about the grass-user mailing list