Scroll to navigation

v.colors(1grass) Grass User's Manual v.colors(1grass)

NAME

v.colors - Set color rules for features in a vector using a numeric attribute column.

KEYWORDS

vector, color table

SYNOPSIS

v.colors
 
v.colors help
 
v.colors [-sn] map=name column=string [ layer=integer] [rgb_column=string] [range= min,max] [color=style] [raster=string] [ rules=string] [placeholder= string] [--overwrite] [--verbose] [-- quiet]

Flags:

-s
 
Save placeholder raster map for use with d.legend
-n
 
Invert colors
--overwrite
 
Allow output files to overwrite existing files
--verbose
 
Verbose module output
--quiet
 
Quiet module output

Parameters:

map=name
 
Name of input vector map
column=string
 
Name of column containing numeric data
layer=integer
 
Layer number of data column
 
Default: 1
rgb_column=string
 
Name of color column to populate
 
Default: GRASSRGB
range=min,max
 
Manually set range (min,max)
color=style
 
Type of color table
 
Options: aspect,aspectcolr,bcyr,bgyr,byg,byr,celsius,corine,curvature,differences,elevation,etopo2,evi,gdd,grey,grey1.0,grey255,grey.eq,grey.log,gyr,haxby,ndvi,population,population_dens,precipitation,precipitation_monthly,rainbow,ramp,random,rstcurv,ryb,ryg,sepia,slope,srtm,terrain,wave
raster=string
 
Raster map name from which to copy color table
rules=string
 
Path to rules file
placeholder=string
 
Dummy raster map name containing color rules for use with d.legend
 
Use with the -s flag (using this option implies -s)

DESCRIPTION

v.colors allows the user to create and/or modify the color table for a vector map. The vector map (specified on the command line by map) must exist in the user's current mapset search path.
As input a vector map with a numeric data column is required which is used to apply the color rules. The color values are stored in a string column (default name "GRASSRGB", varchar(11)) by saving the RRR:GGG:BBB values suitable for use with 'd.vect -a'. If this RGB column is not found in the attribute table, it is automatically created.
How it works: it creates a dummy raster map with the same data range as the vector's column then runs r.colors for that temporary map. It then uses r.what.colors for each value found by v.db.select and uploads it a new column in the vector map's attribute database.
It is planned that this script will be replaced with a C display module which renders thematic vector maps directly instead requiring the overhead of saving the colors into the DB.
If the target column name given by the rgb_column option does not exist, it will be created. The default name is "GRASSRGB".

EXAMPLES

Creating a random sample point map, query raster map values for those points, and colorize output:
 
# Spearfish dataset
 
g.region -d
 
v.random out=rand5k_elev n=5000
 
v.db.addtable map=rand5k_elev column='elevation double precision'
 
v.what.rast vector=rand5k_elev raster=elevation.10m column=elevation
 
v.colors map=rand5k_elev column=elevation color=bcyr
 
 
# See some GRASSRGB values:
 
v.db.select rand5k_elev | head -n 4
 
cat|elevation|GRASSRGB
 
1|1609.643677|255:210:0
 
2|1347.657959|34:255:221
 
3|1142.30835|0:81:255
 
4|1212.105469|0:152:255
 
 
# display colorized points map
 
d.mon x0
 
d.vect -a rand5k_elev
 
Colorizing the roads map in Spearfish:
 
g.copy vect=roads,myroads
 
echo "1 red
 
2 yellow
 
3 orange
 
4 black
 
5 grey" > colors.txt
 
 
v.colors myroads column=cat rules=colors.txt
 
 
# display colorized roads map
 
d.mon x0
 
d.vect -a myroads
 
Colorizing a TIN (polygons) generated by v.delaunay:
 
# new columns for x,y,z of centroids
 
v.db.addtable map=tin \
 

columns="east double precision, north double precision, height double precision, GRASSRGB varchar(11)"
 
 
# transfer geometry for colorizing (we need the centroid height)
 
v.to.db tin option=coor columns="east,north,height"
 
v.db.select tin
 
 
v.colors tin column=height rgb_column=GRASSRGB color=rainbow
 
 
# display colorized triangles
 
d.mon x0
 
d.vect -a tin
 

SEE ALSO

d.vect -z, r.colors, r.colors.stddev, r.what.color, v.db.addcol, v.db.select, db.execute
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.

AUTHOR

Hamish Bowman
 
Dunedin, New Zealand
Last changed: $Date: 2013-02-15 23:04:18 +0100 (Fri, 15 Feb 2013) $
Full index
© 2003-2014 GRASS Development Team
GRASS 6.4.4