3
<i>r.colors</i> allows the user to create and/or modify the color table for a
4
raster map layer. The map layer (specified on the command line by
5
<b>map=</b><i>name</i>) must exist in the user's current mapset search path.
8
The <b>rast</b> option allows user to specify a raster map <i>name</i> from which
12
All color tables are stored in $GISBASE/etc/colors/. Further user-defined color tables
13
can also be stored in this directory for access from the <em>color</em> parameter.
15
The <b>-e</b> flag equalizes the original raster's color table. It can preclude
16
the need for <em>grey.eq</em> rule, when used as
17
<b>-e color=</b><em>grey</em>. Note however, that this will not yield a color
18
table identical to <em>color=grey.eq</em>, because <em>grey.eq</em> scales
19
the fraction by 256 to get a grey level, while <b>-e</b> uses it to interpolate
20
the original colour table. If the original colour table is a 0-255 grey scale,
21
<b>-e</b> is effectively scaling the fraction by 255. Different algorithms are
22
used. <b>-e</b> is designed to work with any color table, both the floating
23
point and the integer raster maps.
26
The <b>-g</b> flag divides the raster's grey value range into 100
27
logarithmically equal steps (where "step" is a rule with the same grey level
28
for the start and end points). It can preclude the need for <em>grey.log</em>
29
rule, when used as <b>-g color=</b><em>grey</em>. Note however, that this
30
will not yield a color table identical to <em>color=grey.log</em>. Different
31
algorithms are used. Unlike <b>color=</b><em>grey.log</em>, <b>-g</b> is
32
designed to work with both floating point and integer rasters, without
33
performance issues with large datasets, of any original color table. Logarithmic
34
scaling doesn't work on negative values. In the case when the value range
35
includes zero, there's no realistic solution.
38
The <b>-e</b> and <b>-g</b> flags are not mutually exclusive.
41
If the user specifies the <b>-w</b> flag, the current color table file for
42
the input map will not be overwritten. This means that the color table is
43
created only if the <i>map</i> does not already have a color table. If this
44
option is not specified, the color table will be created if one does not
45
exist, or modified if it does.
48
If the user sets the <b>-q</b> flag, <i>r.colors</i> will run quietly,
49
Without printing numerous messages on its progress to standard output.
50
<p>Color table types <i>aspect, grey, grey.eq</i> (histogram-equalized grey
51
scale), <i>byg</i> (blue-yellow-green), <i>byr</i> (blue-yellow-red),
52
<i>gyr</i> (green-yellow-red), <i>rainbow, ramp, ryg</i> (red-yellow-green),
53
<i>random</i>, and <i>wave</i> are pre-defined color tables that
54
<i>r.colors</i> knows how to create without any further input.
57
In general, tables which associate colors with percentages (aspect, bcyr, byg,
58
byr, elevation, grey, gyr, rainbow, ramp, ryb, ryg and wave) can be applied to
59
any data, while those which use absolute values (aspectcolr, curvature, etopo2,
60
evi, ndvi, population, slope, srtm, and terrain) only make sense for data with
63
One can get a rough idea of the applicability of a colour table by reading the
64
corresponding rules file ($GISBASE/etc/colors/<name>).
65
For example the <em>slope</em> rule is defined as:
67
<div class="code"><pre>
79
This is designed for the slope map generated by r.slope.aspect, where the value
80
is a slope angle between 0 and 90 degrees.
83
Similarly, the <em>aspectcolr</em> rule:
85
<div class="code"><pre>
95
is designed for the aspect maps produced by r.slope.aspect, where the value is a
96
heading between 0 and 360 degrees.
99
The <i>rules</i> color table type will cause <i>r.colors</i> to read color
100
table specifications from standard input (stdin) and will build the color table
104
Using color table type <i>rules</i>, there are <!--three-->two ways to build a color
105
table: <!--by color list,--> by category values and by "percent" values.
107
<!-- HB: this causes an error in current code, maybe easy to enable functionality from old code??
109
Building a customized color table by color list is the simplest of the three
110
rules methods: just list the colors you wish to appear in the color table in the
111
order that you wish them to appear. Use the standard GRASS color names: white,
112
black, red, green, blue, yellow, magenta, cyan, aqua, grey, gray, orange, brown,
113
purple, violet, and indigo.
116
For example, to create a color table for the raster map layer <i>elevation</i>
117
that assigns greens to low map category values, browns to the next larger
118
map category values, and yellows to the still larger map category values,
121
<div class="code"><pre>
122
<b>r.colors map=</b><i>elevation</i> <b>color=</b><i>rules</i>
130
To build a color table by category values' indices, the user should determine
131
the range of category values in the raster map layer with which the color table
132
will be used. Specific category values will then be associated with specific
133
colors. Note that a color does not have to be assigned for every valid category
134
value because <i>r.colors</i> will interpolate a color ramp to fill in where
135
color specification rules have been left out. The format of such a specification
138
<div class="code"><pre>
139
category_value color_name
140
category_value color_name
143
category_value color_name
148
Each category value must be valid for the raster map layer, category values must
149
be in ascending order and only use standard GRASS color names (aqua, black, blue,
150
brown, cyan, gray, green, grey, indigo, magenta, orange, purple, red, violet, white, yellow).
153
Colors can also be specified by color numbers each in the range 0-255. The
154
format of a category value color table specification using color numbers instead
155
of color names is as follows:
157
<div class="code"><pre>
158
category_value red_number:green_number:blue_number
159
category_value red_number:green_number:blue_number
162
category_value red_number:green_number:blue_number
167
Specifying a color table by "percent" values allows one to treat a color table
168
as if it were numbered from 0 to 100. The format of a "percent" value color
169
table specification is the same as for a category value color specification,
170
except that the category values are replaced by "percent" values, each from
171
0-100, in ascending order. The format is as follows:
173
<div class="code"><pre>
174
percent_value% color_name
175
percent_value% color_name
178
percent_value% color_name
183
Using "percent" value color table specification rules, colors can also
184
be specified by color numbers each in the range 0-255. The format of a
185
percent value color table specification using color numbers instead of
186
color names is as follows:
188
<div class="code"><pre>
189
percent_value% red_number:green_number:blue_number
190
percent_value% red_number:green_number:blue_number
193
percent_value% red_number:green_number:blue_number
198
Note that you can also mix these <!--three-->two methods of color table
199
specification; for example:
201
<div class="code"><pre>
204
78 blue<!--\n magenta
212
To set the NULL (no data) color, use the "nv" parameter:
214
<div class="code"><pre>
222
To set the color to used for undefined values (beyond the range of
223
the color rules) use the "default" parameter:
225
<div class="code"><pre>
235
The below example shows how you can specify colors for a three category map,
236
assigning red to category 1, green to category 2, and blue to category 3. Start
237
by using a text editor to create the following rules specification file (save it
238
with the name <i>rules.file</i>):
240
<div class="code"><pre>
248
The color table can then by assigned to map <i>threecats</i> by the following
249
GRASS commands (two ways are available):
251
<div class="code"><pre>
252
# read input from stdin
253
cat rules.file | r.colors map=threecats color=rules
255
# read directly from file
256
r.colors map=threecats rules=rules.file
260
To create a natural looking lookup table (LUT) for true map layer
261
<i>elevation</i>, use the
262
following rules specification file. It will assign light green shades to the
263
lower elevations (first 20% of the LUT), and then darker greens (next 15%, and
264
next 20%) and light browns (next 20%) for middle elevations, and darker browns
265
(next 15%) for higher elevations, and finally yellow for the highest peaks (last
268
<div class="code"><pre>
279
To invert the current rules:
280
<div class="code"><pre>
281
r.colors current_raster -n rast=current_raster
288
<a href="d.colors.html">d.colors</a>,
289
<a href="d.colortable.html">d.colortable</a>,
290
<a href="d.histogram.html">d.histogram</a>,
291
<a href="d.legend.html">d.legend</a>,
292
<a href="r.colors.stddev.html">r.colors.stddev</a>,
293
<a href="r.support.html">r.support</a>,
294
<a href="r.univar.html">r.univar</a>,
295
<a href="v.colors.html">v.colors</a>
300
page <a href="http://grasswiki.osgeo.org/wiki/Color_tables">Color
301
tables</a> (from GRASS User Wiki)
304
<a href="http://colorbrewer.org">ColorBrewer</a> is an online tool designed to
305
help people select good color schemes for maps and other graphics.
309
Michael Shapiro and David Johnson
312
<i>Last changed: $Date: 2013-02-15 23:04:18 +0100 (Fri, 15 Feb 2013) $</i>