[GRASS-dev] all categories copied over to new map

Paulo van Breugel p.vanbreugel at gmail.com
Wed Sep 16 01:48:34 PDT 2015



On 16-09-15 09:49, Moritz Lennert wrote:
> On 15/09/15 20:08, Paulo van Breugel wrote:
>> Suppose I have a categorical raster map and I want to 'cut out' a subset
>> (with g.region to set a small region and r.mapcalc to create the new
>> map). This map has a smaller number of categories, as is shown using
>> e.g., r.category. However, when plotting the legend, all the categories
>> of the original map are included in the legend. Checking the 'cats' file
>> shows that it indeed lists all original categories and labels, including
>> for those categories not present in the new map. This doesn't make sense
>> to me, but perhaps I am missing something here?
>
> AFAIK, the legend is determined by the color table, and the color 
> table is probably just copied as is from the input to the output map. 
> You can check with r.colors.out. If you redefine a color table with 
> only the relevant categories, then the legend should reflect that.

Hi Moritz, that is what I thought, and as the whole color table does 
indeed get copied over, I wrote a small script to remove the 'redundant 
color definitions. However, that did not help, the whole 'old' legend is 
still showing.  I had missed that -n flag, so I'll give that a try. Is 
there a similar option in ps.map to omit categories without label?

 From a more conceptual point of view, is there any reason the whole 
category table is copied over to the new cats file?

> You could also try d.legend with the -n flag to only show categories 
> which have a label.
>
> Moritz



More information about the grass-dev mailing list