r.colors(1grass)

✨ r.colors ✨

okay bestie, welcome to r.colors from the GRASS User's Manual β€” it's a section 1grass situation, iykyk πŸ’…


🌈 NAME

r.colors β€” creates/modifies the color table associated with a raster map. that's it, that's the whole job, and she does it beautifully 😌

πŸŽ€ 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

grab your lil flag checklist bestie, we're going through all of them:

  • -r β€” remove existing color table. say bye bye, it's giving deletion 🫢
  • -w β€” only write new color table if it does not already exist. so polite of her, she checks first πŸ’–
  • -l β€” list available rules then exit. window shopping, no commitment ✨
  • -d β€” list available rules with description then exit. also: if a color rule is given, only this rule is listed. so you can be like "okay just show me that one" πŸŽ€
  • -n β€” invert colors. flip the whole vibe upside down πŸ”„
  • -g β€” logarithmic scaling
  • -a β€” logarithmic-absolute scaling
  • -e β€” histogram equalization
  • --help β€” print usage summary
  • --verbose β€” verbose module output (she will NOT stop talking and honestly? we love that) πŸ’¬
  • --quiet β€” quiet module output (shhh 🀫)
  • --ui β€” force launching GUI dialog

πŸ“ Parameters

  • map=name[,name,...] β€” name of raster map(s). you can pass a whole lil squad of them, comma-separated πŸ‘‘
  • file=name β€” input file with one map name per line. listen, if you have a large amount of maps to specify, you can define the input map names in an input file instead. > this option is mutual exclusive to the map option β€” so it's map OR file, not both, no cap 🚫
  • color=style β€” name of color table. here's the full lineup, and bestie every single one of these is iconic in her own way:

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 each one πŸ«–:

  • 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 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 β€” [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 πŸ“‹βœ¨
  • raster_3d=name β€” 3D raster map from which to copy color table (yes babe, 3D, she contains multitudes) 🧊
  • rules=name β€” path to rules file. > use "-" to read rules from stdin 🫢
  • 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

πŸ’– DESCRIPTION πŸ’–

okay bestie, so r.colors is the glow-up tool for your raster maps' color tables ✨ You can create a color table, or modify one, or do it for a whole lil squad of raster maps at once. The maps β€” either named on the command line with map, or handed over as a file using input with one map name per line β€” must exist in your current mapset search path, no exceptions, she's picky like that.

  • The raster option lets you name a raster map and just... steal its color map wholesale. copy-paste energy 🫢
  • The raster_3d option does the same thing but for a 3D raster map β€” dimension glow-up πŸ’…

The -e flag equalizes the original raster's color table. It can save you from needing the grey.eq rule when you use it as -e color=grey. BUT β€” and this is the part nobody tells you β€” it will not give you a color table identical to color=grey.eq, because grey.eq scales the fraction by 256 to get a grey level, while -e uses that fraction to interpolate the original color table. If the original color table is a 0-255 grey scale, then -e is effectively scaling the fraction by 255. Different algorithms, different vibes, same goal. -e is designed to work with any color table β€” floating point and integer raster maps both, she doesn't discriminate πŸ”₯

The -g flag divides the raster's grey value range into 100 logarithmically equal steps (where "step" means a rule with the same grey level at its start and end points). It can save you from needing the grey.log rule when you use it as -g color=grey. BUT again β€” this will not produce a color table identical to color=grey.log. Different algorithms, she's her own girl. Unlike color=grey.log, though, -g is designed to work with both floating point and integer rasters, with no performance drama even on huge datasets, whatever the original color table was. Two things to know though:

Logarithmic scaling does not work on negative values. And if the value range includes zero, there is no realistic solution. It's giving undefined, bestie, don't even try 😭

The -e and -g flags are not mutually exclusive β€” you can absolutely run both, they're besties too.

offset and scale modify color rules so they match a raster map's values, using this formula:

new_value = (old_value + offset) x scale

For example, if a raster map's units are Kelvin x 50, you can apply the celsius color rules with offset=273.15 and scale=50. math girlies rise up πŸ”₯

If you pass the -w flag, the current color table file for the input map will not be overwritten. Meaning: the color table only gets created if the map doesn't already have one. If you don't pass -w, then the color table gets created if none exists, or modified if one does. It's the difference between "make it if it's missing" and "make it or fix it, idc" πŸ’…

These color table types are pre-defined, and r.colors knows how to build them with zero extra input from you:

  • aspect
  • grey
  • grey.eq β€” the 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 you provide several input raster maps, the range (min, max) of all of them gets used for color table creation. So the color table she makes will span from the smallest minimum to the largest maximum across every input raster map, and gets applied to all of them. group effort, periodt 🫢

In general, tables that associate colors with percentages β€” aspect, bcyr, byg, byr, elevation, grey, gyr, rainbow, ramp, ryb, ryg and wave β€” can be applied to literally any data. But the ones that 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 whether a color table suits your data by reading the matching 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

That's 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 tells r.colors to read color table specifications from standard input (stdin) and build the color table accordingly. DIY queen πŸ‘‘

Using the rules color table type, there are two ways to build a color table: by category values, and by "percent" values.

To build a color table using category value indices, you figure out the range of category values in the raster map the color table will be used with, then associate specific category values with specific colors. Note that you do not have to assign a color for every valid category value, because r.colors will interpolate a color ramp to fill in wherever color specification rules were left out. The format looks like this:

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

Each category value must be valid for the raster map, the 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. no inventing new colors, sorry babe 😭

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

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

Specifying a color table by "percent" values lets you 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 specification, except the category values get replaced by "percent" values, each from 0-100, in ascending order:

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

And using "percent" value specification rules, colors can also be given as color numbers, each in the range 0-255:

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

Bestie, you can even mix the two methods of color table specification. for example:

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

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

0 black
10% yellow
nv white
end

To set the color used for undefined values (those 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 dropped in this directory so they're accessible from the color parameter β€” or you can keep them in a user defined directory instead. 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/. that's where she lives 🏠


🌸 EXAMPLES 🌸

The example below shows how you can specify colors for a three category map β€” red for category 1, green for category 2, and blue for category 3. Start by opening a text editor and creating this rules specification file (save it with the name rules.file):

1 red
2 green
3 blue
end

Then the color table can be assigned to map threecats with these GRASS commands (two ways are available, pick your fave):

# 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 this rules specification file. It assigns light green shades to the lower elevations (first 20% of the LUT), then darker greens (next 15%, and next 20%) and light browns (next 20%) for middle elevations, darker browns (next 15%) for higher elevations, and finally yellow for the highest peaks (last 10% of the LUT). peak main character energy, honestly πŸ‘‘

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

Also check out the wiki page Color tables (from the GRASS User Wiki) πŸ¦‹

And ColorBrewer β€” an online tool designed to help people select good color schemes for maps and other graphics. aesthetic queen behavior 🎨✨


🫢 AUTHORS 🫢

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


πŸ’» SOURCE CODE πŸ’»

Available at: r.colors source code (history)

Latest change: Thursday Oct 09 18:01:34 2025 in commit: c32823cbb080d14d419b2f734087c7ba396b3e2c

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

Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual


and that's a wrap bestie!! πŸ’– this whole page lives in GRASS 8.5.0 as r.colors(1grass), latest commit dropped Thursday Oct 09 18:01:34 2025 (commit c32823cbb080d14d419b2f734087c7ba396b3e2c), Β© 2003-2026 GRASS Development Team. go forth and color your maps, you're gonna slay πŸŽ€πŸŒˆπŸ’…

πŸ“¦ where this page comes from