## NAME

r.colors - Creates/Modifies the color table associated with a raster map layer.
(GRASS Raster Program)

## SYNOPSIS

r.colors
r.colors help
r.colors [-wq] map=name [color=type] [rast=name]

## DESCRIPTION

r.colors allows the user to create and/or modify the color table for a raster map layer. The map layer (specified on the command line by map=name) must exist in the user's current mapset search path. The color table specified by color=type must be one of the following:

         color type    description
         aspect        (aspect oriented grey colors)
         grey          (grey scale)
         grey.eq       (histogram-equalized grey scale)
         grey.log      (histogram logarithmic transformed grey scale)
         byg           (blue through yellow to green colors)
         byr           (blue through yellow to red colors)
         gyr           (green through yellow to red colors)
         rainbow       (rainbow color table)
         ramp          (color ramp)
         random        (random color table)
         ryg           (red through yellow to green colors)
         wave          (color wave)
         rules         (create new color table based on user-specified rules)

If the user specifies the -w flag, the current color table file for the input map will not be overwritten. This means that the color table is created only if the map does not already have a color table. If this option is not specified, the color table will be created if one does not exist, or modified if it does.

If the user sets the -q flag, r.colors will run quietly, Without printing numerous messages on its progress to standard output.

Color table types aspect, grey, grey.eq (histogram-equalized grey scale), byg (blue-yellow-green), byr (blue-yellow-red), gyr (green-yellow-red), rainbow, ramp, ryg (red-yellow-green), random, and wave are pre-defined color tables that r.colors knows how to create without any further input.

The rules color table type will cause r.colors to read color table specifications from standard input (stdin) and will build the color table accordingly.

Using color table type rules, there are three ways to build a color table: by color list, by category values, and by "percent" values.

Building a customized color table by color list is the simplest of the three rules methods: just list the colors you wish to appear in the color table in the order that you wish them to appear. Use the standard GRASS color names: white, black, red, green, blue, yellow, magenta, cyan, aqua, grey, gray, orange, brown, purple, violet, and indigo.

For example, to create a color table for the raster map layer elevation that assigns greens to low map category values, browns to the next larger map category values, and yellows to the still larger map category values, one would type:

r.colors map=elevation color=rules
green
brown
yellow
end

To build a color table by category values' indices, the user should determine the range of category values in the raster map layer with which the color table will be used. Specific category values will then be associated with specific colors. Note that a color does not have to be assigned for every valid category value because r.colors will interpolate a color ramp to fill in where color specification rules have been left out. The format of such a specification is as follows:

category_value color_name
category_value color_name
.. ..
.. ..
category_value color_name
end

Each category value must be valid for the raster map layer, category values must be in ascending order and only use standard GRASS color names (see above).

Colors can also be specified by color numbers each in the range 0-255. The format of a category value color table specification using color numbers instead of color names is as follows:

category_value red_number green_number blue_number
category_value red_number green_number blue_number
.. .. .. ..
.. .. .. ..
category_value red_number green_number blue_number
end

Specifying a color table by "percent" values allows one to treat a color table as if it were numbered from 0 to 100. The format of a "percent" value color table specification is the same as for a category value color specification, except that the category values are replaced by "percent" values, each from 0-100, in ascending order. The format is as follows:

percent_value% color_name
percent_value% color_name
.. ..
.. ..
percent_value% color_name
end

Using "percent" value color table specification rules, colors can also be specified by color numbers each in the range 0-255. The format of a percent value color table specification using color numbers instead of color names is as follows:

percent_value% red_number green_number blue_number
percent_value% red_number green_number blue_number
.. .. .. ..
.. .. .. ..
percent_value% red_number green_number blue_number
end

Note that you can also mix these three methods of color table specification; for example:

0 black
10% yellow
78 blue
magenta
purple
brown
100% 0 255 230
end

## EXAMPLES

1. The below example shows how you can specify colors for a three category map, assigning red to category 1, green to category 2, and blue to category 3. Start by using a text editor, like vi, to create the following rules specification file. Save it with the name rules.file.

1 red
2 green
3 blue
end

The color table can then by assigned to map threecats by typing the following command at the GRASS> prompt:

  cat rules.file | r.colors map=threecats color=rules

2. To create a natural looking LUT for true map layer elevation, use the following rules specification file. It will assign light green shades to the lower elevations (first 20% of the LUT), and then darker greens (next 15%, and next 20%) and light browns (next 20%) for middle elevations, and darker browns (next 15%) for higher elevations, and finally yellow for the highest peaks (last 10% of LUT).

  0% 0 230 0
20% 0 160 0
35% 50 130 0
55% 120 100 30
75% 120 130 40
90% 170 160 50
100% 255 255 100

Option rast allows user to specify a raster map name from which to copy the color map.

## SEE ALSO

d.colormode
d.colors
d.colortable
d.display
d.legend
p.colors
r.support

## AUTHORS

Michael Shapiro and David Johnson

Last changed: $Date: 2003/02/09 12:07:23 $