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