1r.colors(1) GRASS GIS 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] [off‐
17 set=float] [scale=float] [--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 forest_cover, gdd, grass, greens, grey, grey.eq, grey.log, grey1.0,
72 grey255, gyr, haxby, inferno, kelvin, magma, ndvi, ndwi, nlcd, or‐
73 anges, plasma, population, population_dens, precipitation, precipi‐
74 tation_daily, precipitation_monthly, rainbow, ramp, random, reds,
75 roygbiv, rstcurv, ryb, ryg, sepia, slope, soilmoisture, srtm,
76 srtm_plus, terrain, viridis, 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 r.slope.as‐
88 pect) [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 forest_cover: percentage of forest cover [range: 0 to 100]
98 gdd: accumulated growing degree days [range: 0 to 6000]
99 grass: GRASS GIS green (perceptually uniform) [range: map values]
100 greens: white to green [range: map values]
101 grey: grey scale [range: map values]
102 grey.eq: histogram-equalized grey scale [range: map values]
103 grey.log: histogram logarithmic transformed grey scale [range: map
104 values]
105 grey1.0: grey scale for raster values between 0.0-1.0 [range: 0 to
106 1]
107 grey255: grey scale for raster values between 0-255 [range: 0 to
108 255]
109 gyr: green through yellow to red [range: map values]
110 haxby: relative colors for bathymetry or topography [range: map
111 values]
112 inferno: perceptually uniform sequential color table inferno
113 [range: map values]
114 kelvin: blue to red for temperature in Kelvin scale [range: 193.15
115 to 353.15]
116 magma: perceptually uniform sequential color table magma [range:
117 map values]
118 ndvi: Normalized Difference Vegetation Index colors [range: -1 to
119 1]
120 ndwi: Normalized Difference Water Index colors [range: -200 to
121 200]
122 nlcd: US National Land Cover Dataset colors [range: 0 to 95]
123 oranges: white to orange [range: map values]
124 plasma: perceptually uniform sequential color table plasma [range:
125 map values]
126 population: color table covering human population classification
127 breaks [range: 0 to 2e+09]
128 population_dens: color table covering human population density
129 classification breaks [range: 0 to 1e+09]
130 precipitation: precipitation color table (0..2000mm) [range: 0 to
131 7000]
132 precipitation_daily: precipitation color table (0..1000mm) [range:
133 0 to 10000]
134 precipitation_monthly: precipitation color table (0..1000mm)
135 [range: 0 to 1000]
136 rainbow: rainbow color table [range: map values]
137 ramp: color ramp [range: map values]
138 random: random color table [range: map values]
139 reds: white to red [range: map values]
140 roygbiv: [range: map values]
141 rstcurv: terrain curvature (from r.resamp.rst) [range: map values]
142 ryb: red through yellow to blue [range: map values]
143 ryg: red through yellow to green [range: map values]
144 sepia: yellowish-brown through to white [range: map values]
145 slope: r.slope.aspect-type slope colors for raster values 0-90
146 [range: 0 to 90]
147 soilmoisture: soilmoisture color table (0.0-1.0) [range: 0 to 1]
148 srtm: color palette for Shuttle Radar Topography Mission elevation
149 [range: -11000 to 8850]
150 srtm_plus: color palette for Shuttle Radar Topography Mission ele‐
151 vation (with seafloor colors) [range: -11000 to 8850]
152 terrain: global elevation color table covering -11000 to +8850m
153 [range: -11000 to 8850]
154 viridis: perceptually uniform sequential color table viridis
155 [range: map values]
156 water: water depth [range: map values]
157 wave: color wave [range: map values]
158
159 raster=name
160 Raster map from which to copy color table
161
162 raster_3d=name
163 3D raster map from which to copy color table
164
165 rules=name
166 Path to rules file
167 "-" to read rules from stdin
168
169 offset=float
170 Offset for color rule values
171 New value = (old value + offset) * scale
172 Default: 0
173
174 scale=float
175 Scale for color rule values
176 New value = (old value + offset) * scale
177 Default: 1
178
180 r.colors allows the user to create and/or modify the color table for a
181 raster map or several raster maps at once. The raster maps (specified
182 on the command line by map or as file using an input file with one map
183 name per line) must exist in the user’s current mapset search path.
184
185 The raster option allows user to specify a raster map name from which
186 to copy the color map.
187
188 The raster_3d option allows user to specify a 3D raster map name from
189 which to copy the color map.
190
191 The -e flag equalizes the original raster’s color table. It can pre‐
192 clude the need for grey.eq rule, when used as -e color=grey. Note how‐
193 ever, that this will not yield a color table identical to
194 color=grey.eq, because grey.eq scales the fraction by 256 to get a grey
195 level, while -e uses it to interpolate the original color table. If the
196 original color table is a 0-255 grey scale, -e is effectively scaling
197 the fraction by 255. Different algorithms are used. -e is designed to
198 work with any color table, both the floating point and the integer
199 raster maps.
200
201 The -g flag divides the raster’s grey value range into 100 logarithmi‐
202 cally equal steps (where "step" is a rule with the same grey level for
203 the start and end points). It can preclude the need for grey.log rule,
204 when used as -g color=grey. Note however, that this will not yield a
205 color table identical to color=grey.log. Different algorithms are used.
206 Unlike color=grey.log, -g is designed to work with both floating point
207 and integer rasters, without performance issues with large datasets, of
208 any original color table. Logarithmic scaling doesn’t work on negative
209 values. In the case when the value range includes zero, there’s no re‐
210 alistic solution.
211
212 The -e and -g flags are not mutually exclusive.
213
214 offset and scale modify color rules to match the values of a raster map
215 using the formula new_value = (old_value + offset) x scale. For exam‐
216 ple, if the units of a raster map are Kelvin x 50, the color rules cel‐
217 sius can be applied with offset=273.15 and scale=50.
218
219 If the user specifies the -w flag, the current color table file for the
220 input map will not be overwritten. This means that the color table is
221 created only if the map does not already have a color table. If this
222 option is not specified, the color table will be created if one does
223 not exist, or modified if it does.
224
225 Color table types aspect, grey, grey.eq (histogram-equalized grey
226 scale), byg (blue-yellow-green), byr (blue-yellow-red), gyr (green-yel‐
227 low-red), rainbow, ramp, ryg (red-yellow-green), random, and wave are
228 pre-defined color tables that r.colors knows how to create without any
229 further input.
230
231 In case several input raster maps are provided the range (min, max) of
232 all maps will be used for color table creation. Hence the created color
233 table will span from the smallest minimum to the largest maximum value
234 of all input raster maps and will be applied to all input raster maps.
235
236 In general, tables which associate colors with percentages (aspect,
237 bcyr, byg, byr, elevation, grey, gyr, rainbow, ramp, ryb, ryg and wave)
238 can be applied to any data, while those which use absolute values (as‐
239 pectcolr, curvature, etopo2, evi, ndvi, population, slope, srtm, and
240 terrain) only make sense for data with certain ranges. One can get a
241 rough idea of the applicability of a colour table by reading the corre‐
242 sponding rules file ($GISBASE/etc/colors/<name>). For example the
243 slope rule is defined as:
244 0 255:255:255
245 2 255:255:0
246 5 0:255:0
247 10 0:255 255
248 15 0:0:255
249 30 255:0:255
250 50 255:0:0
251 90 0:0:0
252
253 This is designed for the slope map generated by r.slope.aspect, where
254 the value is a slope angle between 0 and 90 degrees.
255
256 Similarly, the aspectcolr rule:
257 0 white
258 1 yellow
259 90 green
260 180 cyan
261 270 red
262 360 yellow
263
264 is designed for the aspect maps produced by r.slope.aspect, where the
265 value is a heading between 0 and 360 degrees.
266
267 The rules color table type will cause r.colors to read color table
268 specifications from standard input (stdin) and will build the color ta‐
269 ble accordingly.
270
271 Using color table type rules, there are two ways to build a color ta‐
272 ble: by category values and by "percent" values.
273
274 To build a color table by category values’ indices, the user should de‐
275 termine the range of category values in the raster map with which the
276 color table will be used. Specific category values will then be associ‐
277 ated with specific colors. Note that a color does not have to be as‐
278 signed for every valid category value because r.colors will interpolate
279 a color ramp to fill in where color specification rules have been left
280 out. The format of such a specification is as follows:
281 category_value color_name
282 category_value color_name
283 .. ..
284 .. ..
285 category_value color_name
286 end
287
288 Each category value must be valid for the raster map, category values
289 must be in ascending order and only use standard GRASS color names
290 (aqua, black, blue, brown, cyan, gray, green, grey, indigo, magenta,
291 orange, purple, red, violet, white, yellow).
292
293 Colors can also be specified by color numbers each in the range 0-255.
294 The format of a category value color table specification using color
295 numbers instead of color names is as follows:
296 category_value red_number:green_number:blue_number
297 category_value red_number:green_number:blue_number
298 .. .. .. ..
299 .. .. .. ..
300 category_value red_number:green_number:blue_number
301 end
302
303 Specifying a color table by "percent" values allows one to treat a
304 color table as if it were numbered from 0 to 100. The format of a "per‐
305 cent" value color table specification is the same as for a category
306 value color specification, except that the category values are replaced
307 by "percent" values, each from 0-100, in ascending order. The format is
308 as follows:
309 percent_value% color_name
310 percent_value% color_name
311 .. ..
312 .. ..
313 percent_value% color_name
314 end
315
316 Using "percent" value color table specification rules, colors can also
317 be specified by color numbers each in the range 0-255. The format of a
318 percent value color table specification using color numbers instead of
319 color names is as follows:
320 percent_value% red_number:green_number:blue_number
321 percent_value% red_number:green_number:blue_number
322 .. .. .. ..
323 .. .. .. ..
324 percent_value% red_number:green_number:blue_number
325 end
326
327 Note that you can also mix these two methods of color table specifica‐
328 tion; for example:
329 0 black
330 10% yellow
331 78 blue
332 100% 0:255:230
333 end
334
335 To set the NULL (no data) color, use the "nv" (null values) parameter:
336 0 black
337 10% yellow
338 nv white
339 end
340
341 To set the color to used for undefined values (beyond the range of the
342 color rules) use the "default" parameter:
343 0 red
344 1 blue
345 default grey
346 end
347
349 All color tables are stored in $GISBASE/etc/colors/. Further user-de‐
350 fined color tables can also be stored in this directory for access from
351 the color parameter or in a user defined directory. See also r.col‐
352 ors.out for printing color tables easily to the terminal.
353
354 The color table assigned to a raster map is stored in $GISDBASE/loca‐
355 tion/mapset/colr/.
356
358 The below example shows how you can specify colors for a three category
359 map, assigning red to category 1, green to category 2, and blue to cat‐
360 egory 3. Start by using a text editor to create the following rules
361 specification file (save it with the name rules.file):
362 1 red
363 2 green
364 3 blue
365 end
366
367 The color table can then by assigned to map threecats by the following
368 GRASS commands (two ways are available):
369 # read input from stdin
370 cat rules.file | r.colors map=threecats rules=-
371 # read directly from file
372 r.colors map=threecats rules=rules.file
373
374 To create a natural looking lookup table (LUT) for true map layer ele‐
375 vation, use the following rules specification file. It will assign
376 light green shades to the lower elevations (first 20% of the LUT), and
377 then darker greens (next 15%, and next 20%) and light browns (next 20%)
378 for middle elevations, and darker browns (next 15%) for higher eleva‐
379 tions, and finally yellow for the highest peaks (last 10% of LUT).
380 0% 0:230:0
381 20% 0:160:0
382 35% 50:130:0
383 55% 120:100:30
384 75% 120:130:40
385 90% 170:160:50
386 100% 255:255:100
387
388 To invert the current rules:
389 r.colors map=current_raster -n rast=current_raster
390
392 d.colortable, d.histogram, d.legend, r.colors.out r.colors.stddev,
393 r.support, r.univar, v.colors, v.colors.out, r3.colors, r3.colors.out
394
395 See also wiki page Color tables (from GRASS User Wiki)
396
397 ColorBrewer is an online tool designed to help people select good color
398 schemes for maps and other graphics.
399
401 Michael Shapiro and David Johnson
402 Support for 3D rasters by Soeren Gebbert
403
405 Available at: r.colors source code (history)
406
407 Accessed: Saturday Oct 28 18:17:28 2023
408
409 Main index | Raster index | Topics index | Keywords index | Graphical
410 index | Full index
411
412 © 2003-2023 GRASS Development Team, GRASS GIS 8.3.1 Reference Manual
413
414
415
416GRASS 8.3.1 r.colors(1)