[GRASS-user] colortable RGB value for a pixel based on its value?

Glynn Clements glynn at gclements.plus.com
Sat Oct 20 13:56:17 PDT 2012

Carlos Grohmann wrote:

> I'm trying to do dome tricks with r.colors.stddev and was wondering if
> there is a way to know which RGB value will be assigned to a raster value?
> More precisely, I want to use the r.colors.stddev scheme in a
> moving-window, so that the central pixel is colored
> using r.colors.stddev but using only the values of its surrounding pixels.

Use r.neighbors and r.mapcalc, e.g.:

r.neighbors "input=$inmap" "output=$tmpmap.mean" method=average
r.neighbors "input=$inmap" "output=$tmpmap.sdev" method=stddev
r.mapcalc "$outmap = ($inmap - $tmpmap.mean) / $tmpmap.sdev"
r.colors "$outmap" rules=- <<EOF
0% blue
-2 blue
0 white
2 red
100% red
g.remove "rast=$tmpmap.mean,$tmpmap.sdev"

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list