v.colors.out
Exports the color table associated with a vector map.
v.colors.out [-p] map=name [layer=string] [rules=name] [column=name] format=name color_format=name [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
v.colors.out map=name format=plain color_format=hex
grass.script.parse_command("v.colors.out", map, layer="1", rules=None, column=None, format="plain", color_format="hex", flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)
Example:
gs.parse_command("v.colors.out", map="name", format="json", color_format="hex")
grass.tools.Tools.v_colors_out(map, layer="1", rules=None, column=None, format="plain", color_format="hex", flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)
Example:
tools = Tools()
tools.v_colors_out(map="name", format="json", color_format="hex")
This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.
Parameters
map=name [required]
Name of vector map
Or data source for direct OGR access
layer=string
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 1
rules=name
Path to output rules file
If not given write to standard output
column=name
Name of attribute (numeric) column to which refer color rules
If not given, color rules refer to categories
format=name [required]
Output format
Allowed values: plain, json
Default: plain
plain: Plain text output
json: JSON (JavaScript Object Notation)
color_format=name [required]
Color format
Color format for output values.
Allowed values: rgb, hex, hsv, triplet
Default: hex
rgb: output color in RGB format
hex: output color in HEX format
hsv: output color in HSV format (experimental)
triplet: output color in colon-separated RGB format
-p
Output values as percentages
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
map : str, required
Name of vector map
Or data source for direct OGR access
Used as: input, vector, name
layer : str, optional
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Used as: input, layer
Default: 1
rules : str, optional
Path to output rules file
If not given write to standard output
Used as: output, file, name
column : str, optional
Name of attribute (numeric) column to which refer color rules
If not given, color rules refer to categories
Used as: input, dbcolumn, name
format : str, required
Output format
Used as: name
Allowed values: plain, json
plain: Plain text output
json: JSON (JavaScript Object Notation)
Default: plain
color_format : str, required
Color format
Color format for output values.
Used as: name
Allowed values: rgb, hex, hsv, triplet
rgb: output color in RGB format
hex: output color in HEX format
hsv: output color in HSV format (experimental)
triplet: output color in colon-separated RGB format
Default: hex
flags : str, optional
Allowed values: p
p
Output values as percentages
overwrite : bool, optional
Allow output files to overwrite existing files
Default: None
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
map : str, required
Name of vector map
Or data source for direct OGR access
Used as: input, vector, name
layer : str, optional
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Used as: input, layer
Default: 1
rules : str, optional
Path to output rules file
If not given write to standard output
Used as: output, file, name
column : str, optional
Name of attribute (numeric) column to which refer color rules
If not given, color rules refer to categories
Used as: input, dbcolumn, name
format : str, required
Output format
Used as: name
Allowed values: plain, json
plain: Plain text output
json: JSON (JavaScript Object Notation)
Default: plain
color_format : str, required
Color format
Color format for output values.
Used as: name
Allowed values: rgb, hex, hsv, triplet
rgb: output color in RGB format
hex: output color in HEX format
hsv: output color in HSV format (experimental)
triplet: output color in colon-separated RGB format
Default: hex
flags : str, optional
Allowed values: p
p
Output values as percentages
overwrite : bool, optional
Allow output files to overwrite existing files
Default: None
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
Returns:
result : grass.tools.support.ToolResult | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None
will be returned.
DESCRIPTION
v.colors.out allows the user to export the color table for a vector map to a file which is suitable as input to v.colors.
Alternatively, the color rules can be exported as a JSON format with format=json, to use them in other software. The color format in JSON can be modified using the color_format parameter, which includes the following options:
- hex: #00BFBF
- rgb: rgb(0, 191, 191)
- hsv: hsv(180, 100, 74)
- triplet: 0:191:191
EXAMPLES
== "Command line"
```sh
v.colors map=bridges color=plasma column="YEAR_BUILT"
v.colors.out map=bridges
```
Shortened output:
```text
6388 13:8:135
662 79:2:162
9097 94:1:166
20 98:0:167
903 98:0:167
905 98:0:167
2161 98:0:167
3439 98:0:167
5192 105:0:168
7157 105:0:168
...
```
=== "Python (grass.script)"
```python
import grass.script as gs
gs.run_command("v.colors", map="bridges", color="plasma", column="YEAR_BUILT")
colors = gs.parse_command("v.colors.out", map="bridges", format="json")
```
The shortened JSON output looks like:
```json
[
{
"value": 6388,
"color": "#0D0887"
},
{
"value": 662,
"color": "#4F02A2"
},
{
"value": 9097,
"color": "#5E01A6"
},
{
"value": 20,
"color": "#6200A7"
},
...
]
```
SEE ALSO
v.colors, r.colors, r3.colors, r.colors.out, r3.colors.out
AUTHOR
Martin Landa, Czech Technical University in Prague, Czech Republic
SOURCE CODE
Available at: v.colors.out source code
(history)
Latest change: Wednesday Jun 25 11:38:52 2025 in commit b90b316