v.colors(1)

πŸ’… v.colors β€” the GRASS GIS User's Manual glow-up, part 1 πŸŽ€

okay bestie, pull up a chair, we're reading the v.colors page from the GRASS GIS User's Manual and I am so excited to tell you about it. sit down. hydrate. this is a long one so we're doing it in two parts πŸ’–


✨ NAME ✨

v.colors β€” creates/modifies the color table associated with a vector map. that's it. that's the whole job. and she does it beautifully πŸ‘‘


🏷️ KEYWORDS 🏷️

vector, color table

(ngl that's the whole keyword list, short and sweet, we love a minimal icon ✨)


🌈 SYNOPSIS 🌈

v.colors
v.colors --help
v.colors [-rwldngac] map=name  [layer=string]  use=string  [column=name]
[range=min,max]   [color=style]   [raster=name]   [raster_3d=name]
[rules=name]   [rgb_column=name]   [--help]  [--verbose]  [--quiet]
[--ui]

literally the whole vibe in one block. let's break it down πŸ’…


🚩 Flags 🚩

  • -r β€” removes the existing color table. bye bye color table, you were iconic while you lasted πŸ’€
  • -w β€” only writes the new color table if it does not already exist. so respectful. so "no means no" energy 🫢
  • -l β€” lists the available rules, then exits. window shopping, no commitment πŸ›οΈ
  • -d β€” lists available rules with description, then exits. and if a color rule is given, only that rule is listed. she's specific like that πŸ’…
  • -n β€” inverts the colors. negative. upside down. opposite day πŸŒ—
  • -g β€” logarithmic scaling πŸ“ˆ
  • -a β€” logarithmic-absolute scaling πŸ“‰
  • -c β€” converts color rules from RGB values to a color table. heads up: the rgb_column option with valid RGB values is required for this one, no cap ⚠️
  • --help β€” prints the usage summary πŸ₯Ί
  • --verbose β€” verbose module output. she talks more πŸ’¬
  • --quiet β€” quiet module output. she talks less 🀫
  • --ui β€” forces launching the GUI dialog. clicky clicky ✨

πŸŽ€ Parameters πŸŽ€

  • map=name [required] β€” name of the vector map. or, plot twist, the data source for direct OGR access πŸ‘€
  • layer=string β€” layer number or name. because vector features can have category values in different layers, this number decides which layer we're using. when it's used with direct OGR access, this is the layer name instead. default: 1 🧚
  • use=string [required] β€” source values. options: attr, cat, z. default: cat
    • attr: read values from the attribute table (this one requires the <column> option, don't forget it bestie)
    • cat: use category values
    • z: use the z coordinate (3D points or centroids only, no 3D lines allowed 🚫)
  • column=name β€” name of the column containing numeric data. required when use=attr ⚠️
  • range=min,max β€” manually set the range (this refers to the column option, iykyk). it gets ignored when rules is given, so don't even try πŸ’…
  • color=style β€” name of the color table. okay this is the big one, the main character, the moment. options are:

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, with her range in brackets β˜•:

  • 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: [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 the color table 🎁
  • raster_3d=name β€” 3D raster map from which to copy the color table 🎁✨
  • rules=name β€” path to the rules file πŸ“„
  • rgb_column=name β€” name of the color column to populate with RGB values. if it's not given, she writes a color table instead πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

v.colors lets you create or modify the color table associated with a vector map, and she does it similarly to r.colors for raster maps. sister modules, same energy 🫢

Color rules are built from features' category values (use=cat) or from a numeric data column (use=attr) defined by the column option. and for 3D vector maps, you're allowed to define color rules based on points' or centroids' z-coordinate (use=z). ⚠️ but listen β€” 3D vector lines are not supported. not today, not ever, we don't do that here 🚫

The raster option lets you specify a raster map to copy the color table from, and similarly the raster_3d option does the same for a 3D raster map. and here's the trick bestie: without use=attr and column, the raster values will be matched with categories. so use those two options when you wanna transfer raster colors over to vector attributes ✨

The rules color table type will make v.colors read color table specifications from the given file and build the color table accordingly. see the r.colors manual page for the details, she explains it better than me πŸ’–

now, if the user specifies the -w flag, the current color table file for the input map will not be overwritten. what that means is: the color table only gets created if the vector map doesn't already have one. if you don't pass that option, then the color table gets created if one doesn't exist, or modified if one does. so it's giving "create or edit" energy either way πŸ’…

Alternatively β€” plot twist β€” the color rules can be stored in a string column (rgb_column) by saving the RRR:GGG:BBB values, which are suitable for use with d.vect. storing the drip directly in your data, iconic ✨


πŸ“ NOTES πŸ“

okay real talk: for vector maps with a large number of features, it's more convenient to store color rules in an attribute column (the one given by rgb_column) rather than in a color table file. why? because reading color tables with more than 1000 items is slow. 😭 like, painfully slow. so if you're out here with a million features, put those rules in the column, bestie. future you will thank you 🫢


part 1 done and we are NOT done yet β€” part 2 is coming, don't go anywhere πŸ’–

🎨 EXAMPLES 🎨

okay bestie this is the part where it all clicks, fr fr. every example below is copy-paste-able, so grab a snack and let's go πŸ’…


Define color table based on categories

want a color table called wave, built off the categories sitting in layer 1? say less:

v.colors map=soils_general layer=1 color=wave

Define color table based on attribute values

now we're pulling from an attribute column instead of just categories β€” here it's AREA, and the attribute table is linked to layer 1. first, get the area values into the table:

v.to.db map=soils_general layer=1 option=area column=AREA

then build a ryg color table from those values:

v.colors map=soils_general layer=1 color=wave use=attr column=AREA

Define color table stored as RGB values in attribute table

different vibe: instead of creating a color table, you write the color values straight into the attribute table, into column GRASSRGB:

v.colors map=soils_general layer=1 color=wave use=attr column=AREA rgb_column=GRASSRGB

and because we're nosy, here's how you peek at some GRASSRGB values:

# See some GRASSRGB values:
v.db.select map=soils_general where="cat < 4"
cat|OBJECTID|AREA|PERIMETER|GSLNC250_|GSLNC250_I|GSL_NAME|GRASSRGB
1|1|0|164616.125|2|1|NC113|212:42:127
2|2|0|30785.529297|3|2|NC096|212:42:127
3|3|0|87572.882812|4|3|NC097|212:42:127

Convert RGB attribute values into color table

already got RGB values sitting in a column and want actual color table rules out of them? boom:

v.colors -c map=soils_general rgb_column=GRASSRGB
heads up bestie πŸ‘€ in this case the vector map ends up with a proper color table assigned (verify it with v.colors.out) and the GRASSRGB attribute column. also note that the color table wins β€” it's preferred over the RGB values stored in the attribute table.

Transfer raster colors to vector

the classic glow-up: steal the colors from a raster and give them to your vector. first, make an example raster out of census blocks at 10m pixel resolution:

# create an example raster from census blocks (10m pixel resolution)
g.region vector=censusblk_swwake res=10 -ap
v.to.rast input=censusblk_swwake use=attr attribute_column=TOTAL_POP output=censusblk_swwake_total_pop
r.colors -e map=censusblk_swwake_total_pop color=blues

then transfer those raster colors over to the vector attributes (raster values β†’ attributes):

# transfer raster colors to vector attributes (raster values to attributes)
r.colors.out map=censusblk_swwake_total_pop rules=- | v.colors map=censusblk_swwake use=attr column=TOTAL_POP rules=-

and here's the equivalent move, just simpler:

# equivalent, but simpler
v.colors map=censusblk_swwake use=attr column=TOTAL_POP raster=censusblk_swwake_total_pop

or send raster colors to the vector categories instead (raster values β†’ categories):

# transfer raster colors to vector categories (raster values to categories)
v.colors map=censusblk_swwake raster=censusblk_swwake_total_pop

Remove existing color table

want it gone? the -r flag does the deleting:

v.colors -r map=soils_general

pro tip from me to you πŸ’– before you nuke a color table, save the rules to a file with v.colors.out, then reassign them later using the rules option:

v.colors.out map=soils_general rules=soils.colr
v.colors map=soils_general rules=soils.colr

and to drop an RGB column entirely, use v.db.dropcolumn:

v.db.dropcolumn map=soils_general column=GRASSRGB

πŸ‘€ SEE ALSO πŸ‘€

  • d.vect, r.colors, r.colors.out, r3.colors, r3.colors.out, v.colors.out

also peep the wiki page Color tables (from GRASS User Wiki).

and ColorBrewer is an online tool designed to help people select good color schemes for maps and other graphics. it's giving palette Pinterest 🎨✨


πŸ‘‘ AUTHORS πŸ‘‘

  • Martin Landa, OSGeoREL, Czech Technical University in Prague, Czech Republic
  • Huidae Cho

πŸ’Ύ SOURCE CODE πŸ’Ύ

available at: v.colors source code (history)

accessed: Saturday Jan 17 05:41:19 2026

Main index | Vector 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 and you absolutely ate 🫢 this was GRASS 8.4.2's v.colors(1) β€” go forth and make your maps pretty, no cap πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from