[GRASS-user] Defining color table rules

Greetings all

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?

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?

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?

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

5- One last question :slight_smile: 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

Thanks for your help :slight_smile:

Best regards,
Pedro Roma

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
blank.

[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
backwards compatibility).

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 :slight_smile: 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@gclements.plus.com>

Glynn wrote:

color=rules is only kept in 6.4 for backwards compatibility).

the interactive setting from the command line is useful too.

> Pedro Roma wrote:
> 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

Glynn:

Odd;

I think that's the GUI code catching any $0 set as d.*.

Hamish

Glynn, thanks for your answer. But, for instance in GUI if a select a type of color table and then I decide to user a rule file, there is no blank option in “Type of color table”. And if I choose rule, it gets an error. So, in this cases I just have to close r.colors window and open one again. This may sound a bit unclear .

But thanks
Pedro

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
blank.

[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
backwards compatibility).

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 :slight_smile: 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@gclements.plus.com>

Pedro wrote:

for instance in GUI if a select a type of color table and
then I decide to user a rule file, there is no blank option
in "Type of color table". And if I choose rule, it
gets an error. So, in this cases I just have to close
r.colors window and open one again.

fixed in 6.5svn, for 6.4.x this will probably have to wait for
6.4.1 when it has had more testing. (& I would not be surprised
if it works in older versions of grass and this was a recent
breakage)

Hamish