r3.colors.out
Exports the color table associated with a 3D raster map.
r3.colors.out [-p] map=name [rules=name] format=name color_format=name [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
r3.colors.out map=name format=plain color_format=hex
grass.script.parse_command("r3.colors.out", map, rules=None, format="plain", color_format="hex", flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.parse_command("r3.colors.out", map="name", format="json", color_format="hex")
Parameters
map=name [required]
Name of 3D raster map
rules=name
Path to output rules file
If not given write to standard output
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 3D raster map
Used as: input, raster_3d, name
rules : str, optional
Path to output rules file
If not given write to standard output
Used as: output, file, 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: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
r3.colors.out allows the user to export the color table for a 3D raster map to a file which is suitable as input to r3.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
r3.mapcalc "random = rand(1, 5)" -s
r3.colors map=random color=gyr
r3.colors.out map=random
Output:
1 0:255:0
2.5 255:255:0
4 255:0:0
nv 255:255:255
default 255:255:255
=== "Python (grass.script)"
```python
import grass.script as gs
gs.run_command("r3.mapcalc", expression="random = rand(1, 5)", flags="s")
gs.run_command("r3.colors", map="random", color="gyr")
colors = gs.parse_command("r3.colors.out", map="random", format="json")
```
The JSON output looks like:
```json
[
{
"value": 1,
"color": "#00FF00"
},
{
"value": 2.5,
"color": "#FFFF00"
},
{
"value": 4,
"color": "#FF0000"
},
{
"value": "nv",
"color": "#FFFFFF"
},
{
"value": "default",
"color": "#FFFFFF"
}
]
```
SEE ALSO
r.colors, r.colors.out, r3.colors v.colors, v.colors.out
AUTHOR
Glynn Clements
SOURCE CODE
Available at: r3.colors.out source code
(history)
Latest change: Wednesday Jun 25 11:38:52 2025 in commit b90b316