3
<em>r.colors</em> allows the user to create and/or modify the color
4
table for a raster map or several raster maps at once.
5
The raster maps (specified on the command line
6
by <b>map</b> or as <b>file</b> using an input file with one map name per line)
7
must exist in the user's current mapset search path.
9
<p>The <b>raster</b> option allows user to specify a raster map <i>name</i>
10
from which to copy the color map.
12
<p>The <b>raster_3d</b> option allows user to specify a 3D raster
13
map <i>name</i> from which to copy the color map.
15
<p>The <b>-e</b> flag equalizes the original raster's color table. It can
16
preclude 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
18
a color table identical to <em>color=grey.eq</em>,
19
because <em>grey.eq</em> scales the fraction by 256 to get a grey
20
level, while <b>-e</b> uses it to interpolate the original color
21
table. If the original color table is a 0-255 grey scale, <b>-e</b>
22
is effectively scaling the fraction by 255. Different algorithms are
23
used. <b>-e</b> is designed to work with any color table, both the
24
floating point and the integer raster maps.
26
<p>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
28
same grey level for the start and end points). It can preclude the
29
need for <em>grey.log</em> rule, when used as <b>-g
30
color=</b><em>grey</em>. Note however, that this will not yield a
31
color table identical to <em>color=grey.log</em>. Different algorithms
32
are used. Unlike <b>color=</b><em>grey.log</em>, <b>-g</b> is designed
33
to work with both floating point and integer rasters, without
34
performance issues with large datasets, of any original color
35
table. Logarithmic scaling doesn't work on negative values. In the
36
case when the value range includes zero, there's no realistic
39
<p>The <b>-e</b> and <b>-g</b> flags are not mutually exclusive.
41
<p>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.
47
<p><p>Color table types <i>aspect, grey, grey.eq</i> (histogram-equalized
48
grey scale), <i>byg</i> (blue-yellow-green), <i>byr</i>
49
(blue-yellow-red), <i>gyr</i> (green-yellow-red), <i>rainbow, ramp,
50
ryg</i> (red-yellow-green), <i>random</i>, and <i>wave</i> are
51
pre-defined color tables that <em>r.colors</em> knows how to create
52
without any further input.
55
In case several input raster maps are provided the range (min, max) of all maps
56
will be used for color table creation. Hence the created color table will span from
57
the smallest minimum to the largest maximum value of all input raster maps and
58
will be applied to all input raster maps.
60
<p>In general, tables which associate colors with percentages (aspect, bcyr, byg,
61
byr, elevation, grey, gyr, rainbow, ramp, ryb, ryg and wave) can be applied to
62
any data, while those which use absolute values (aspectcolr, curvature, etopo2,
63
evi, ndvi, population, slope, srtm, and terrain) only make sense for data with
66
One can get a rough idea of the applicability of a colour table by reading the
67
corresponding rules file (<tt>$GISBASE/etc/colors/<name></tt>).
68
For example the <em>slope</em> rule is defined as:
70
<div class="code"><pre>
81
<p>This is designed for the slope map generated
82
by <em><a href="r.slope.aspect.html">r.slope.aspect</a></em>, where the
83
value is a slope angle between 0 and 90 degrees.
85
<p>Similarly, the <em>aspectcolr</em> rule:
87
<div class="code"><pre>
96
<p>is designed for the aspect maps produced
97
by <em><a href="r.slope.aspect.html">r.slope.aspect</a></em>, where the
98
value is a heading between 0 and 360 degrees.
100
<p>The <b>rules</b> color table type will cause <i>r.colors</i> to read
101
color table specifications from standard input (stdin) and will build
102
the color table accordingly.
104
<p>Using color table type <b>rules</b>, there are <!--three-->two ways to
105
build a color table: <!--by color list,--> by category values and by
106
"percent" values.
108
<!-- HB: this causes an error in current code, maybe easy to enable functionality from old code??
109
<p>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.
115
<p>For example, to create a color table for the raster map layer <i>elevation</i>
116
that assigns greens to low map category values, browns to the next larger
117
map category values, and yellows to the still larger map category values,
120
<div class="code"><pre>
121
<b>r.colors map=</b><i>elevation</i> <b>color=</b><i>rules</i>
128
<p>To build a color table by category values' indices, the user should
129
determine the range of category values in the raster map with which
130
the color table will be used. Specific category values will then be
131
associated with specific colors. Note that a color does not have to be
132
assigned for every valid category value because <em>r.colors</em> will
133
interpolate a color ramp to fill in where color specification rules
134
have been left out. The format of such a specification is as follows:
136
<div class="code"><pre>
137
category_value color_name
138
category_value color_name
141
category_value color_name
145
<p>Each category value must be valid for the raster map, category values
146
must be in ascending order and only use standard GRASS color names
147
(aqua, black, blue, brown, cyan, gray, green, grey, indigo, magenta,
148
orange, purple, red, violet, white, yellow).
150
<p>Colors can also be specified by color numbers each in the range
151
0-255. The format of a category value color table specification using
152
color numbers instead of color names is as follows:
154
<div class="code"><pre>
155
category_value red_number:green_number:blue_number
156
category_value red_number:green_number:blue_number
159
category_value red_number:green_number:blue_number
163
<p>Specifying a color table by "percent" values allows one to
164
treat a color table as if it were numbered from 0 to 100. The format
165
of a "percent" value color table specification is the same
166
as for a category value color specification, except that the category
167
values are replaced by "percent" values, each from 0-100, in
168
ascending order. The format is as follows:
170
<div class="code"><pre>
171
percent_value% color_name
172
percent_value% color_name
175
percent_value% color_name
179
<p>Using "percent" value color table specification rules,
180
colors can also be specified by color numbers each in the range
181
0-255. The format of a percent value color table specification using
182
color numbers instead of color names is as follows:
184
<div class="code"><pre>
185
percent_value% red_number:green_number:blue_number
186
percent_value% red_number:green_number:blue_number
189
percent_value% red_number:green_number:blue_number
193
<p>Note that you can also mix these <!--three-->two methods of color
194
table specification; for example:
196
<div class="code"><pre>
199
78 blue<!--\n magenta
206
<p>To set the NULL (no data) color, use the "nv" parameter:
208
<div class="code"><pre>
215
<p>To set the color to used for undefined values (beyond the range of the
216
color rules) use the "default" parameter:
218
<div class="code"><pre>
227
All color tables are stored in <tt>$GISBASE/etc/colors/</tt>. Further
228
user-defined color tables can also be stored in this directory for
229
access from the <em>color</em> parameter or in a user defined directory.
230
See also <em>r.colors.out</em> for printing color tables easily to the
233
The color table assigned to a raster map is stored in
234
<tt>$GISDBASE/location/mapset/colr/</tt>.
238
The below example shows how you can specify colors for a three
239
category map, assigning red to category 1, green to category 2, and
240
blue to category 3. Start by using a text editor to create the
241
following rules specification file (save it with the
242
name <i>rules.file</i>):
244
<div class="code"><pre>
251
<p>The color table can then by assigned to map <i>threecats</i> by the
252
following GRASS commands (two ways are available):
254
<div class="code"><pre>
255
# read input from stdin
256
cat rules.file | r.colors map=threecats rules=-
258
# read directly from file
259
r.colors map=threecats rules=rules.file
262
<p>To create a natural looking lookup table (LUT) for true map layer
263
<i>elevation</i>, use the following rules specification file. It will
264
assign light green shades to the lower elevations (first 20% of the
265
LUT), and then darker greens (next 15%, and next 20%) and light browns
266
(next 20%) for middle elevations, and darker browns (next 15%) for
267
higher elevations, and finally yellow for the highest peaks (last 10%
270
<div class="code"><pre>
280
<p>To invert the current rules:
281
<div class="code"><pre>
282
r.colors map=current_raster -n rast=current_raster
288
<a href="d.colortable.html">d.colortable</a>,
289
<a href="d.histogram.html">d.histogram</a>,
290
<a href="d.legend.html">d.legend</a>,
291
<a href="r.colors.out.html">r.colors.out</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>,
296
<a href="v.colors.out.html">v.colors.out</a>,
297
<a href="r3.colors.html">r3.colors</a>,
298
<a href="r3.colors.out.html">r3.colors.out</a>
302
page <a href="http://grasswiki.osgeo.org/wiki/Color_tables">Color
303
tables</a> (from GRASS User Wiki)
305
<p><a href="http://colorbrewer.org">ColorBrewer</a> is an online tool designed to
306
help people select good color schemes for maps and other graphics.
310
Michael Shapiro and David Johnson<br>
311
Support for 3D rasters by Soeren Gebbert
313
<p><i>Last changed: $Date: 2014-12-24 11:56:44 +0100 (Wed, 24 Dec 2014) $</i>