[GRASS-user] Defining color table rules
glynn at gclements.plus.com
Tue Jan 19 11:56:02 EST 2010
Pedro Roma wrote:
> I'm reading r.colors manual webpage (
> http://grass.itc.it/grass64/manuals/html64_user/r.colors.html) and I have a
> few questions related with defining new color tables.
> 1- At color (in Parameters) one of the options is rules. But if i select
> rules and insert a path to a rules file I get this error:
> *ERROR: "color", "rules", and "raster" options are mutually exclusive*
> Was this suppose to happen?
Yes. If you specify a file for "rules", the "color" option should be
[color=rules exists for compatibility with previous versions, and only
works from the command-line, not the GUI.]
> 2- About color tables with absolute values (e.g. NDVI) if a NDVI pixel has
> value between 2 defined values, which color does it get?
It's interpolated. This is true whether the rules uses absolute values
or percentages (or a mix of both).
> 3- About aspectcolr*.* To each category a color is assigned (e.g. white,
> yellow bla bla bla). Is there a list of possible colors to assign?
The list of named colours is:
white black red green blue yellow magenta cyan aqua grey gray
orange brown purple violet indigo
You can mix named colours and r:g:b notation freely.
> 4- Regarding assigning a rules.info to a map (as it's demonstrated in the
> same manual page). There are two ways. How come r.colors can use, as an
> input, rules.info if it's stated before the r.colors statement.
> cat rules.file | r.colors map=threecats color=rules
color=rules reads rules from stdin, which in the above example is the
contents of the rules.file via "cat". The following commands will
all achieve the same result:
cat rules.file | r.colors map=threecats rules=-
r.colors map=threecats color=rules < rules.file
r.colors map=threecats rules=- < rules.file
r.colors map=threecats rules=rules.file
For reading from a file, the last one is preferable (and is the only
one which will work from the GUI). Beyond that, using rules=- is
preferred to color=rules (apart from anything else, rules=- works in
7.0 while color=rules doesn't; color=rules is only kept in 6.4 for
The use of "cat file | ..." rather than "... < file" can be easier to
read if you're creating a long pipeline in a script, as it places the
source file at the far left of the command. The following both have
the same effect:
cat infile | cmd1 | cmd2 | ... | cmdN > outfile
cmd1 < infile | cmd2 | ... | cmdN > outfile
but the former is probbably clearer.
> 5- One last question :) I tried to display the color table associated with a
> raster map layer (d.colortable) but I get the following message:
> Command 'd.colortable' not yet implemented
Odd; you can try d.legend instead, or use r.mapcalc to create a test
map to which you can assign the colour table.
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user