1r.colors(1) Grass User's Manual r.colors(1)
2
3
4
6 r.colors - Creates/modifies the color table associated with a raster
7 map.
8
10 raster, color table
11
13 r.colors
14 r.colors --help
15 r.colors [-rwldngae] [map=name[,name,...]] [file=name]
16 [color=style] [raster=name] [raster_3d=name] [rules=name]
17 [--help] [--verbose] [--quiet] [--ui]
18
19 Flags:
20 -r
21 Remove existing color table
22
23 -w
24 Only write new color table if it does not already exist
25
26 -l
27 List available rules then exit
28
29 -d
30 List available rules with description then exit
31 If a color rule is given, only this rule is listed
32
33 -n
34 Invert colors
35
36 -g
37 Logarithmic scaling
38
39 -a
40 Logarithmic-absolute scaling
41
42 -e
43 Histogram equalization
44
45 --help
46 Print usage summary
47
48 --verbose
49 Verbose module output
50
51 --quiet
52 Quiet module output
53
54 --ui
55 Force launching GUI dialog
56
57 Parameters:
58 map=name[,name,...]
59 Name of raster map(s)
60
61 file=name
62 Input file with one map name per line
63 Input map names can be defined in an input file in case a large
64 amount of maps must be specified. This option is mutual exclusive
65 to the map option.
66
67 color=style
68 Name of color table
69 Options: aspect, aspectcolr, bcyr, bgyr, blues, byg, byr, celsius,
70 corine, curvature, differences, elevation, etopo2, evi, fahrenheit,
71 gdd, grass, greens, grey, grey.eq, grey.log, grey1.0, grey255, gyr,
72 haxby, inferno, kelvin, magma, ndvi, ndwi, oranges, plasma, popula‐
73 tion, population_dens, precipitation, precipitation_daily, precipi‐
74 tation_monthly, rainbow, ramp, random, reds, roygbiv, rstcurv, ryb,
75 ryg, sepia, slope, soilmoisture, srtm, srtm_plus, terrain, viridis,
76 water, wave
77 aspect: aspect oriented grey colors [range: map values]
78 aspectcolr: aspect oriented rainbow colors [range: 0 to 360]
79 bcyr: blue through cyan through yellow to red [range: map values]
80 bgyr: blue through green through yellow to red [range: map values]
81 blues: white to blue [range: map values]
82 byg: blue through yellow to green [range: map values]
83 byr: blue through yellow to red [range: map values]
84 celsius: blue to red for degree Celsius temperature [range: -80 to
85 80]
86 corine: EU Corine land cover colors [range: 111 to 995]
87 curvature: for terrain curvatures (from v.surf.rst and
88 r.slope.aspect) [range: map values]
89 differences: differences oriented colors [range: map values]
90 elevation: maps relative ranges of raster values to elevation
91 color ramp [range: map values]
92 etopo2: colors for ETOPO2 worldwide bathymetry/topography [range:
93 -11000 to 8850]
94 evi: enhanced vegetative index colors [range: -1 to 1]
95 fahrenheit: blue to red for Fahrenheit temperature [range: -112 to
96 176]
97 gdd: accumulated growing degree days [range: 0 to 6000]
98 grass: GRASS GIS green (perceptually uniform) [range: map values]
99 greens: white to green [range: map values]
100 grey: grey scale [range: map values]
101 grey.eq: histogram-equalized grey scale [range: map values]
102 grey.log: histogram logarithmic transformed grey scale [range: map
103 values]
104 grey1.0: grey scale for raster values between 0.0-1.0 [range: 0 to
105 1]
106 grey255: grey scale for raster values between 0-255 [range: 0 to
107 255]
108 gyr: green through yellow to red [range: map values]
109 haxby: relative colors for bathymetry or topography [range: map
110 values]
111 inferno: perceptually uniform sequential color table inferno
112 [range: map values]
113 kelvin: blue to red for temperature in Kelvin scale [range: 193.15
114 to 353.15]
115 magma: perceptually uniform sequential color table magma [range:
116 map values]
117 ndvi: Normalized Difference Vegetation Index colors [range: -1 to
118 1]
119 ndwi: Normalized Difference Water Index colors [range: -200 to
120 200]
121 oranges: white to orange [range: map values]
122 plasma: perceptually uniform sequential color table plasma [range:
123 map values]
124 population: color table covering human population classification
125 breaks [range: 0 to 2e+09]
126 population_dens: color table covering human population density
127 classification breaks [range: 0 to 1e+09]
128 precipitation: precipitation color table (0..2000mm) [range: 0 to
129 7000]
130 precipitation_daily: precipitation color table (0..1000mm) [range:
131 0 to 10000]
132 precipitation_monthly: precipitation color table (0..1000mm)
133 [range: 0 to 1000]
134 rainbow: rainbow color table [range: map values]
135 ramp: color ramp [range: map values]
136 random: random color table [range: map values]
137 reds: white to red [range: map values]
138 roygbiv: [range: map values]
139 rstcurv: terrain curvature (from r.resamp.rst) [range: map values]
140 ryb: red through yellow to blue [range: map values]
141 ryg: red through yellow to green [range: map values]
142 sepia: yellowish-brown through to white [range: map values]
143 slope: r.slope.aspect-type slope colors for raster values 0-90
144 [range: 0 to 90]
145 soilmoisture: soilmoisture color table (0.0-1.0) [range: 0 to 1]
146 srtm: color palette for Shuttle Radar Topography Mission elevation
147 [range: -11000 to 8850]
148 srtm_plus: color palette for Shuttle Radar Topography Mission ele‐
149 vation (with seafloor colors) [range: -11000 to 8850]
150 terrain: global elevation color table covering -11000 to +8850m
151 [range: -11000 to 8850]
152 viridis: perceptually uniform sequential color table viridis
153 [range: map values]
154 water: water depth [range: map values]
155 wave: color wave [range: map values]
156
157 raster=name
158 Raster map from which to copy color table
159
160 raster_3d=name
161 3D raster map from which to copy color table
162
163 rules=name
164 Path to rules file
165 "-" to read rules from stdin
166
168 r.colors allows the user to create and/or modify the color table for a
169 raster map or several raster maps at once. The raster maps (specified
170 on the command line by map or as file using an input file with one map
171 name per line) must exist in the user’s current mapset search path.
172
173 The raster option allows user to specify a raster map name from which
174 to copy the color map.
175
176 The raster_3d option allows user to specify a 3D raster map name from
177 which to copy the color map.
178
179 The -e flag equalizes the original raster’s color table. It can pre‐
180 clude the need for grey.eq rule, when used as -e color=grey. Note how‐
181 ever, that this will not yield a color table identical to
182 color=grey.eq, because grey.eq scales the fraction by 256 to get a grey
183 level, while -e uses it to interpolate the original color table. If the
184 original color table is a 0-255 grey scale, -e is effectively scaling
185 the fraction by 255. Different algorithms are used. -e is designed to
186 work with any color table, both the floating point and the integer
187 raster maps.
188
189 The -g flag divides the raster’s grey value range into 100 logarithmi‐
190 cally equal steps (where "step" is a rule with the same grey level for
191 the start and end points). It can preclude the need for grey.log rule,
192 when used as -g color=grey. Note however, that this will not yield a
193 color table identical to color=grey.log. Different algorithms are used.
194 Unlike color=grey.log, -g is designed to work with both floating point
195 and integer rasters, without performance issues with large datasets, of
196 any original color table. Logarithmic scaling doesn’t work on negative
197 values. In the case when the value range includes zero, there’s no
198 realistic solution.
199
200 The -e and -g flags are not mutually exclusive.
201
202 If the user specifies the -w flag, the current color table file for the
203 input map will not be overwritten. This means that the color table is
204 created only if the map does not already have a color table. If this
205 option is not specified, the color table will be created if one does
206 not exist, or modified if it does.
207
208 Color table types aspect, grey, grey.eq (histogram-equalized grey
209 scale), byg (blue-yellow-green), byr (blue-yellow-red), gyr (green-yel‐
210 low-red), rainbow, ramp, ryg (red-yellow-green), random, and wave are
211 pre-defined color tables that r.colors knows how to create without any
212 further input.
213
214 In case several input raster maps are provided the range (min, max) of
215 all maps will be used for color table creation. Hence the created color
216 table will span from the smallest minimum to the largest maximum value
217 of all input raster maps and will be applied to all input raster maps.
218
219 In general, tables which associate colors with percentages (aspect,
220 bcyr, byg, byr, elevation, grey, gyr, rainbow, ramp, ryb, ryg and wave)
221 can be applied to any data, while those which use absolute values
222 (aspectcolr, curvature, etopo2, evi, ndvi, population, slope, srtm, and
223 terrain) only make sense for data with certain ranges. One can get a
224 rough idea of the applicability of a colour table by reading the corre‐
225 sponding rules file ($GISBASE/etc/colors/<name>). For example the
226 slope rule is defined as:
227 0 255:255:255
228 2 255:255:0
229 5 0:255:0
230 10 0:255 255
231 15 0:0:255
232 30 255:0:255
233 50 255:0:0
234 90 0:0:0
235
236 This is designed for the slope map generated by r.slope.aspect, where
237 the value is a slope angle between 0 and 90 degrees.
238
239 Similarly, the aspectcolr rule:
240 0 white
241 1 yellow
242 90 green
243 180 cyan
244 270 red
245 360 yellow
246
247 is designed for the aspect maps produced by r.slope.aspect, where the
248 value is a heading between 0 and 360 degrees.
249
250 The rules color table type will cause r.colors to read color table
251 specifications from standard input (stdin) and will build the color ta‐
252 ble accordingly.
253
254 Using color table type rules, there are two ways to build a color ta‐
255 ble: by category values and by "percent" values.
256
257 To build a color table by category values’ indices, the user should
258 determine the range of category values in the raster map with which the
259 color table will be used. Specific category values will then be associ‐
260 ated with specific colors. Note that a color does not have to be
261 assigned for every valid category value because r.colors will interpo‐
262 late a color ramp to fill in where color specification rules have been
263 left out. The format of such a specification is as follows:
264 category_value color_name
265 category_value color_name
266 .. ..
267 .. ..
268 category_value color_name
269 end
270
271 Each category value must be valid for the raster map, category values
272 must be in ascending order and only use standard GRASS color names
273 (aqua, black, blue, brown, cyan, gray, green, grey, indigo, magenta,
274 orange, purple, red, violet, white, yellow).
275
276 Colors can also be specified by color numbers each in the range 0-255.
277 The format of a category value color table specification using color
278 numbers instead of color names is as follows:
279 category_value red_number:green_number:blue_number
280 category_value red_number:green_number:blue_number
281 .. .. .. ..
282 .. .. .. ..
283 category_value red_number:green_number:blue_number
284 end
285
286 Specifying a color table by "percent" values allows one to treat a
287 color table as if it were numbered from 0 to 100. The format of a "per‐
288 cent" value color table specification is the same as for a category
289 value color specification, except that the category values are replaced
290 by "percent" values, each from 0-100, in ascending order. The format is
291 as follows:
292 percent_value% color_name
293 percent_value% color_name
294 .. ..
295 .. ..
296 percent_value% color_name
297 end
298
299 Using "percent" value color table specification rules, colors can also
300 be specified by color numbers each in the range 0-255. The format of a
301 percent value color table specification using color numbers instead of
302 color names is as follows:
303 percent_value% red_number:green_number:blue_number
304 percent_value% red_number:green_number:blue_number
305 .. .. .. ..
306 .. .. .. ..
307 percent_value% red_number:green_number:blue_number
308 end
309
310 Note that you can also mix these two methods of color table specifica‐
311 tion; for example:
312 0 black
313 10% yellow
314 78 blue
315 100% 0:255:230
316 end
317
318 To set the NULL (no data) color, use the "nv" (null values) parameter:
319 0 black
320 10% yellow
321 nv white
322 end
323
324 To set the color to used for undefined values (beyond the range of the
325 color rules) use the "default" parameter:
326 0 red
327 1 blue
328 default grey
329 end
330
332 All color tables are stored in $GISBASE/etc/colors/. Further
333 user-defined color tables can also be stored in this directory for
334 access from the color parameter or in a user defined directory. See
335 also r.colors.out for printing color tables easily to the terminal.
336
337 The color table assigned to a raster map is stored in $GISDBASE/loca‐
338 tion/mapset/colr/.
339
341 The below example shows how you can specify colors for a three category
342 map, assigning red to category 1, green to category 2, and blue to cat‐
343 egory 3. Start by using a text editor to create the following rules
344 specification file (save it with the name rules.file):
345 1 red
346 2 green
347 3 blue
348 end
349
350 The color table can then by assigned to map threecats by the following
351 GRASS commands (two ways are available):
352 # read input from stdin
353 cat rules.file | r.colors map=threecats rules=-
354 # read directly from file
355 r.colors map=threecats rules=rules.file
356
357 To create a natural looking lookup table (LUT) for true map layer ele‐
358 vation, use the following rules specification file. It will assign
359 light green shades to the lower elevations (first 20% of the LUT), and
360 then darker greens (next 15%, and next 20%) and light browns (next 20%)
361 for middle elevations, and darker browns (next 15%) for higher eleva‐
362 tions, and finally yellow for the highest peaks (last 10% of LUT).
363 0% 0:230:0
364 20% 0:160:0
365 35% 50:130:0
366 55% 120:100:30
367 75% 120:130:40
368 90% 170:160:50
369 100% 255:255:100
370
371 To invert the current rules:
372 r.colors map=current_raster -n rast=current_raster
373
375 d.colortable, d.histogram, d.legend, r.colors.out r.colors.stddev,
376 r.support, r.univar, v.colors, v.colors.out, r3.colors, r3.colors.out
377
378 See also wiki page Color tables (from GRASS User Wiki)
379
380 ColorBrewer is an online tool designed to help people select good color
381 schemes for maps and other graphics.
382
384 Michael Shapiro and David Johnson
385 Support for 3D rasters by Soeren Gebbert
386
387 Last changed: $Date: 2018-02-21 11:25:20 +0100 (Wed, 21 Feb 2018) $
388
390 Available at: r.colors source code (history)
391
392 Main index | Raster index | Topics index | Keywords index | Graphical
393 index | Full index
394
395 © 2003-2019 GRASS Development Team, GRASS GIS 7.6.0 Reference Manual
396
397
398
399GRASS 7.6.0 r.colors(1)