r.colors(1)

๐ŸŒˆ NAME ๐ŸŒˆ

Welcome to the GRASS GIS User's Manual bestie, buckle up ๐Ÿ’–

r.colors โ€” creates/modifies the color table associated with a raster map.

Like. It gives your raster a glow-up. A whole aesthetic. ๐Ÿ‘‘


๐ŸŽ€ KEYWORDS ๐ŸŽ€

raster, color table


โœจ SYNOPSIS โœจ

r.colors
r.colors --help
r.colors [-rwldngae] [map=name[,name,...]] [file=name] [color=style] [raster=name] [raster_3d=name] [rules=name] [offset=float] [scale=float] [--help] [--verbose] [--quiet] [--ui]

๐Ÿšฉ Flags ๐Ÿšฉ

  • -r โ€” Remove existing color table. Gone. Yeeted. Not your problem anymore ๐Ÿ’…
  • -w โ€” Only write new color table if it does not already exist. She's shy, she won't overwrite anything that's already there ๐Ÿซถ
  • -l โ€” List available rules then exit. Just showing you the menu, no ordering ๐Ÿ“‹
  • -d โ€” List available rules with description then exit. If a color rule is given, only this rule is listed. The deluxe version of -l โœจ
  • -n โ€” Invert colors. Flip it, reverse it, turn that whole palette upside down ๐Ÿ”„
  • -g โ€” Logarithmic scaling. Math but make it color ๐Ÿ“ˆ
  • -a โ€” Logarithmic-absolute scaling. The absolute-value sibling of -g, no cap.
  • -e โ€” Histogram equalization. Spreading the vibes evenly across the range ๐ŸŒˆ
  • --help โ€” Print usage summary. Your little cheat sheet ๐Ÿฅบ
  • --verbose โ€” Verbose module output. She talks a LOT.
  • --quiet โ€” Quiet module output. She says nothing. Iconic.
  • --ui โ€” Force launching GUI dialog. Clicks instead of types ๐Ÿ–ฑ๏ธ

๐ŸŽ›๏ธ Parameters ๐ŸŽ›๏ธ

  • map=name[,name,...] โ€” Name of raster map(s). You can hand her a whole squad of maps, separated by commas ๐Ÿ‘ฏ
  • file=name โ€” Input file with one map name per line.

Input map names can be defined in an input file in case a large amount of maps must be specified. This option is mutual exclusive to the map option. (So pick a lane bestie โ€” map OR file, not both ๐Ÿšซ)

  • color=style โ€” Name of color table. This is the main character of the whole page, lowkey.

Options: aspect, aspectcolr, bcyr, bgyr, blues, byg, byr, celsius, corine, curvature, differences, elevation, etopo2, evi, fahrenheit, forest_cover, gdd, grass, greens, grey, grey.eq, grey.log, grey1.0, grey255, gyr, haxby, inferno, kelvin, magma, ndvi, ndwi, nlcd, oranges, plasma, population, population_dens, precipitation, precipitation_daily, precipitation_monthly, rainbow, ramp, random, reds, roygbiv, rstcurv, ryb, ryg, sepia, slope, soilmoisture, srtm, srtm_percent, srtm_plus, terrain, viridis, water, wave

And now the tea on every single one of them โ˜•:

  • aspect โ€” aspect oriented grey colors [range: map values]
  • aspectcolr โ€” aspect oriented rainbow colors [range: 0 to 360]
  • bcyr โ€” blue through cyan through yellow to red [range: map values]
  • bgyr โ€” blue through green through yellow to red [range: map values]
  • blues โ€” white to blue [range: map values]
  • byg โ€” blue through yellow to green [range: map values]
  • byr โ€” blue through yellow to red [range: map values]
  • celsius โ€” blue to red for degree Celsius temperature [range: -80 to 80]
  • corine โ€” EU Corine land cover colors [range: 111 to 995]
  • curvature โ€” for terrain curvatures (from v.surf.rst and r.slope.aspect) [range: map values]
  • differences โ€” differences oriented colors [range: map values]
  • elevation โ€” maps relative ranges of raster values to elevation color ramp [range: map values]
  • etopo2 โ€” colors for ETOPO2 worldwide bathymetry/topography [range: -11000 to 8850]
  • evi โ€” enhanced vegetative index colors [range: -1 to 1]
  • fahrenheit โ€” blue to red for Fahrenheit temperature [range: -112 to 176]
  • forest_cover โ€” percentage of forest cover [range: 0 to 100]
  • gdd โ€” accumulated growing degree days [range: 0 to 6000]
  • grass โ€” GRASS GIS green (perceptually uniform) [range: map values]
  • greens โ€” white to green [range: map values]
  • grey โ€” grey scale [range: map values]
  • grey.eq โ€” histogram-equalized grey scale [range: map values]
  • grey.log โ€” histogram logarithmic transformed grey scale [range: map values]
  • grey1.0 โ€” grey scale for raster values between 0.0-1.0 [range: 0 to 1]
  • grey255 โ€” grey scale for raster values between 0-255 [range: 0 to 255]
  • gyr โ€” green through yellow to red [range: map values]
  • haxby โ€” relative colors for bathymetry or topography [range: map values]
  • inferno โ€” perceptually uniform sequential color table inferno [range: map values]
  • kelvin โ€” blue to red for temperature in Kelvin scale [range: 193.15 to 353.15]
  • magma โ€” perceptually uniform sequential color table magma [range: map values]
  • ndvi โ€” Normalized Difference Vegetation Index colors [range: -1 to 1]
  • ndwi โ€” Normalized Difference Water Index colors [range: -200 to 200]
  • nlcd โ€” US National Land Cover Dataset colors [range: 0 to 95]
  • oranges โ€” white to orange [range: map values]
  • plasma โ€” perceptually uniform sequential color table plasma [range: map values]
  • population โ€” color table covering human population classification breaks [range: 0 to 2e+09]
  • population_dens โ€” color table covering human population density classification breaks [range: 0 to 1e+09]
  • precipitation โ€” precipitation color table (0..2000mm) [range: 0 to 7000]
  • precipitation_daily โ€” precipitation color table (0..1000mm) [range: 0 to 10000]
  • precipitation_monthly โ€” precipitation color table (0..1000mm) [range: 0 to 1000]
  • rainbow โ€” rainbow color table [range: map values]
  • ramp โ€” color ramp [range: map values]
  • random โ€” random color table [range: map values]
  • reds โ€” white to red [range: map values]
  • roygbiv โ€” (the manual literally leaves this one blank, bestie, it's a mystery ๐Ÿ•ต๏ธ) [range: map values]
  • rstcurv โ€” terrain curvature (from r.resamp.rst) [range: map values]
  • ryb โ€” red through yellow to blue [range: map values]
  • ryg โ€” red through yellow to green [range: map values]
  • sepia โ€” yellowish-brown through to white [range: map values]
  • slope โ€” r.slope.aspect-type slope colors for raster values 0-90 [range: 0 to 90]
  • soilmoisture โ€” soilmoisture color table (0.0-1.0) [range: 0 to 1]
  • srtm โ€” color palette for Shuttle Radar Topography Mission elevation [range: -11000 to 8850]
  • srtm_percent โ€” color palette for Shuttle Radar Topography Mission using relative elevation [range: map values]
  • srtm_plus โ€” color palette for Shuttle Radar Topography Mission elevation (with seafloor colors) [range: -11000 to 8850]
  • terrain โ€” global elevation color table covering -11000 to +8850m [range: -11000 to 8850]
  • viridis โ€” perceptually uniform sequential color table viridis [range: map values]
  • water โ€” water depth [range: map values]
  • wave โ€” color wave [range: map values]
  • raster=name โ€” Raster map from which to copy color table. Steal her look, respectfully ๐Ÿ’–
  • raster_3d=name โ€” 3D raster map from which to copy color table. Same energy, extra dimension ๐ŸงŠ
  • rules=name โ€” Path to rules file. And "-" to read rules from stdin, if you're feeling spicy ๐ŸŒถ๏ธ
  • offset=float โ€” Offset for color rule values.

New value = (old value + offset) * scale

Default: 0

  • scale=float โ€” Scale for color rule values.

New value = (old value + offset) * scale

Default: 1


โœจ and there's still MORE of this page, so don't you dare scroll away ๐Ÿ‘€

โœจ DESCRIPTION โœจ

okay bestie, so r.colors is the glow-up tool for your raster maps ๐ŸŽจ โ€” it lets you create and/or modify the color table for one raster map or like, several raster maps at once. The maps you name (either straight up on the command line with map, or from a file using an input file with one map name per line) have to already exist in your current mapset search path. No map, no makeover, sorry babe. ๐Ÿ’…

The raster option lets you say "hey, copy the color map from this raster map" โ€” instant inspo. ๐Ÿ‘‘

The raster_3d option does the same thing but for a 3D raster map โ€” copy that color map, periodt.


The -e flag equalizes the original raster's color table. It can preclude the need for the grey.eq rule, when used as -e color=grey. โš ๏ธ BUT โ€” and this is important โ€” it will not yield a color table identical to color=grey.eq, because grey.eq scales the fraction by 256 to get a grey level, while -e uses it to interpolate the original color table. If the original color table is a 0-255 grey scale, -e is effectively scaling the fraction by 255. Different algorithms are used. The -e flag is designed to work with any color table, both the floating point and the integer raster maps. ๐ŸŒˆ

The -g flag divides the raster's grey value range into 100 logarithmically equal steps (where "step" is a rule with the same grey level for the start and end points). It can preclude the need for the grey.log rule, when used as -g color=grey. โš ๏ธ BUT again โ€” it will not yield a color table identical to color=grey.log. Different algorithms are used. Unlike color=grey.log, -g is designed to work with both floating point and integer rasters, without performance issues with large datasets, of any original color table. ๐Ÿฆ‹ Heads up though: logarithmic scaling doesn't work on negative values. And in the case when the value range includes zero, there's no realistic solution. ๐Ÿ˜ญ

Good news: the -e and -g flags are not mutually exclusive โ€” you can absolutely run both. โœจ


offset and scale modify color rules to match the values of a raster map using the formula:

new_value = (old_value + offset) x scale

For example, if the units of a raster map are Kelvin x 50, the color rules celsius can be applied with offset=273.15 and scale=50. ๐Ÿงฎ slay.

If you specify the -w flag, the current color table file for the input map will not be overwritten. This means the color table is created only if the map does not already have a color table. If you don't pass this option, the color table will be created if one doesn't exist, or modified if it does. no cap. ๐Ÿ’…


๐ŸŒธ The pre-defined color table types ๐ŸŒธ

These are the color table types that r.colors just knows how to create, no extra input required:

  • aspect
  • grey
  • grey.eq (histogram-equalized grey scale)
  • byg (blue-yellow-green)
  • byr (blue-yellow-red)
  • gyr (green-yellow-red)
  • rainbow
  • ramp
  • ryg (red-yellow-green)
  • random
  • wave

In case several input raster maps are provided, the range (min, max) of all maps will be used for color table creation. So the created color table will span from the smallest minimum to the largest maximum value of all input raster maps, and will be applied to all input raster maps. ๐Ÿ‘‘


๐ŸŽ€ percentages vs. absolute values ๐ŸŽ€

In general, tables which associate colors with percentages (aspect, bcyr, byg, byr, elevation, grey, gyr, rainbow, ramp, ryb, ryg and wave) can be applied to any data โ€” they're versatile like that, main character energy. ๐Ÿ’–

While those which use absolute values (aspectcolr, curvature, etopo2, evi, ndvi, population, slope, srtm, and terrain) only make sense for data with certain ranges. ๐Ÿ™ˆ

You can get a rough idea of the applicability of a colour table by reading the corresponding rules file at $GISBASE/etc/colors/<name>. For example the slope rule is defined as:

0  255:255:255
2  255:255:0
5  0:255:0
10 0:255 255
15 0:0:255
30 255:0:255
50 255:0:0
90 0:0:0

This is designed for the slope map generated by r.slope.aspect, where the value is a slope angle between 0 and 90 degrees. ๐Ÿ“

Similarly, the aspectcolr rule:

0 white
1 yellow
90 green
180 cyan
270 red
360 yellow

is designed for the aspect maps produced by r.slope.aspect, where the value is a heading between 0 and 360 degrees. ๐Ÿงญ


๐Ÿ’œ the rules color table type ๐Ÿ’œ

The rules color table type will cause r.colors to read color table specifications from standard input (stdin) and will build the color table accordingly.

Using color table type rules, there are two ways to build a color table: by category values and by "percent" values. Let's break it down bestie.

๐Ÿ“ by category values

To build a color table by category values' indices, you should determine the range of category values in the raster map with which the color table will be used. Specific category values will then be associated with specific colors. ๐Ÿ’…

Note that a color does not have to be assigned for every valid category value, because r.colors will interpolate a color ramp to fill in where color specification rules have been left out. The format of such a specification is as follows:

category_value color_name
category_value color_name
.. ..
.. ..
category_value color_name
end

Each category value must be valid for the raster map, category values must be in ascending order, and you can only use standard GRASS color names (aqua, black, blue, brown, cyan, gray, green, grey, indigo, magenta, orange, purple, red, violet, white, yellow). ๐ŸŒˆ

Colors can also be specified by color numbers, each in the range 0-255. The format of a category value color table specification using color numbers instead of color names is as follows:

category_value red_number:green_number:blue_number
category_value red_number:green_number:blue_number
.. .. .. ..
.. .. .. ..
category_value red_number:green_number:blue_number
end

๐Ÿฆ‹ by "percent" values

Specifying a color table by "percent" values allows one to treat a color table as if it were numbered from 0 to 100. The format of a "percent" value color table specification is the same as for a category value color specification, except that the category values are replaced by "percent" values, each from 0-100, in ascending order. The format is as follows:

percent_value% color_name
percent_value% color_name
.. ..
.. ..
percent_value% color_name
end

Using "percent" value color table specification rules, colors can also be specified by color numbers, each in the range 0-255. The format of a percent value color table specification using color numbers instead of color names is as follows:

percent_value% red_number:green_number:blue_number
percent_value% red_number:green_number:blue_number
.. .. .. ..
.. .. .. ..
percent_value% red_number:green_number:blue_number
end

โœจ mixing it up โœจ

Note that you can also mix these two methods of color table specification; for example:

0 black
10% yellow
78 blue
100% 0:255:230
end

๐Ÿ™ˆ NULL and undefined values

To set the NULL (no data) color, use the "nv" (null values) parameter:

0 black
10% yellow
nv white
end

To set the color to be used for undefined values (beyond the range of the color rules) use the "default" parameter:

0 red
1 blue
default grey
end

๐Ÿ’– NOTES ๐Ÿ’–

All color tables are stored in $GISBASE/etc/colors/. Further user-defined color tables can also be stored in this directory for access from the color parameter, or in a user defined directory. See also r.colors.out for printing color tables easily to the terminal. ๐Ÿ–ฅ๏ธ

The color table assigned to a raster map is stored in $GISDBASE/location/mapset/colr/. ๐Ÿ’พ


๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

The below example shows how you can specify colors for a three category map, assigning red to category 1, green to category 2, and blue to category 3. Start by using a text editor to create the following rules specification file (save it with the name rules.file):

1 red
2 green
3 blue
end

The color table can then be assigned to map threecats by the following GRASS commands (two ways are available):

# read input from stdin
cat rules.file | r.colors map=threecats rules=-
# read directly from file
r.colors map=threecats rules=rules.file

To create a natural looking lookup table (LUT) for true map layer elevation, use the following rules specification file. It will assign light green shades to the lower elevations (first 20% of the LUT), and then darker greens (next 15%, and next 20%) and light browns (next 20%) for middle elevations, and darker browns (next 15%) for higher elevations, and finally yellow for the highest peaks (last 10% of LUT). ๐Ÿ”๏ธ

0% 0:230:0
20% 0:160:0
35% 50:130:0
55% 120:100:30
75% 120:130:40
90% 170:160:50
100% 255:255:100

To invert the current rules:

r.colors map=current_raster -n rast=current_raster

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

d.colortable, d.histogram, d.legend, r.colors.out r.colors.stddev, r.support, r.univar, v.colors, v.colors.out, r3.colors, r3.colors.out

See also wiki page Color tables (from GRASS User Wiki) ๐Ÿ“–

ColorBrewer is an online tool designed to help people select good color schemes for maps and other graphics. ๐ŸŽจโœจ


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Michael Shapiro and David Johnson Support for 3D rasters by Soeren Gebbert


๐Ÿ’œ SOURCE CODE ๐Ÿ’œ

Available at: r.colors source code (history)

Accessed: Saturday Jan 17 05:40:45 2026

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

ยฉ 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual


okay that's the whole page bestie, you made it to the end ๐Ÿซถ this was the GRASS GIS 8.4.2 version of r.colors(1), all snuggled into the GRASS 8.4.2 Reference Manual โ€” go forth and color your rasters, you absolute icon ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from