Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.
NAME
r.category.trim - Export categories and corresponding colors as QGIS color file or csv file. Non-existing categories and their color definitions will be removed.
KEYWORDS
raster,
color,
color table,
category
SYNOPSIS
r.category.trim
r.category.trim --help
r.category.trim [-n] input=name [output=name] [csv=name] [qgis=name] [--overwrite] [--help] [--verbose] [--quiet] [--ui]
Flags:
- -n
- Recode layer to get consecutive category values
- --overwrite
- Allow output files to overwrite existing files
- --help
- Print usage summary
- --verbose
- Verbose module output
- --quiet
- Quiet module output
- --ui
- Force launching GUI dialog
Parameters:
- input=name [required]
- input map
- output=name
- output map
- csv=name
- Attribute table (csv format)
- qgis=name
- QGIS color file (txt format)
In GRASS you can 'cut out' a subset of a larger raster layer by
setting the extent to something smaller than the extent of the
original map using g.region and/or by setting a mask using r.mask,
after which you simply run r.mapcalc "newmap = oldmap".
You may have noticed that when creating the new map, all
category labels and colour table of the original map are copied over
to the new map, even for category values that are not in the new
map. If you are working with categorical maps, this may not be what
you want. See
here for a more detailed discussion.
With this addon you can trim the category and colour tables so it
only contains category labels and colour definitions for the values
present in the new map. You can do this on the input map, or do this
on a copy of the map.
If you prefer the map to have consecutive values (i.e., without
gaps), there is the option to change the category values to a
consecutive series by setting the n-flag. For example, if the map
has the following categories values and labels (after the redundant
category labels have been removed):
2 label2
5 label5
9 label9
Then the new recoded layer will have the category values and labels:
1 label2
2 label5
3 label9
The addon let's you export the categories, category labels and
colours as QGIS colour map file. This is just a simple text file
with the raster categories and corresponding colour definitions and
category labels. QGIS can use this to set the colour and labels for
a raster layer. See
this blogpost for more details how to use the colour map
file in QGIS. Alternatively, you can also export the categories and
category labels as a normal comma separated values (CSV) file,
which can be easily viewed in a spreadsheet program such as
Libre/Open Office Calc, Microsoft Excel, or Google Docs and can be
easily shared together with an exported raster file for users that
use other GIS programs.
The file is only useful for categorical maps. Therefore only integer maps are
accepted as input. To export color maps for continuous raster layers (or as an
alternative to this plugin), have a look at the r.colors.out_sld plugin. To
get QGIS color files, you need a two-step approach: (1) create a sld file using
the r.colors.out_sld plugin, and (2) in QGIS, use the SLD4raster plugin to
convert this to a qml file.
When you use the option to recode the map, you need to set an
output map as well. It uses the r.recode
function, with the 'a' flag set, i.e., the region is
aligned to the input raster map.
See
here for examples
r.category,
r.colors,
r.recode
r.colors.out_sld
Paulo van Breugel, paulo at ecodiv.earth
SOURCE CODE
Available at:
r.category.trim source code
(history)
Latest change: Monday Jun 24 15:24:04 2024 in commit: ed8af2507854cdbc4ca37087dd43927d6329c0d4
Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.
Main index |
Raster index |
Topics index |
Keywords index |
Graphical index |
Full index
© 2003-2023
GRASS Development Team,
GRASS GIS 8.2.2dev Reference Manual