<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 17, 2015 at 11:56 AM, Moritz Lennert <span dir="ltr"><<a href="mailto:mlennert@club.worldonline.be" target="_blank">mlennert@club.worldonline.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 16/09/15 10:48, Paulo van Breugel wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On 16-09-15 09:49, Moritz Lennert wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 15/09/15 20:08, Paulo van Breugel wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Suppose I have a categorical raster map and I want to 'cut out' a subset<br>
(with g.region to set a small region and r.mapcalc to create the new<br>
map). This map has a smaller number of categories, as is shown using<br>
e.g., r.category. However, when plotting the legend, all the categories<br>
of the original map are included in the legend. Checking the 'cats' file<br>
shows that it indeed lists all original categories and labels, including<br>
for those categories not present in the new map. This doesn't make sense<br>
to me, but perhaps I am missing something here?<br>
</blockquote>
<br>
AFAIK, the legend is determined by the color table, and the color<br>
table is probably just copied as is from the input to the output map.<br>
You can check with r.colors.out. If you redefine a color table with<br>
only the relevant categories, then the legend should reflect that.<br>
</blockquote>
<br>
Hi Moritz, that is what I thought, and as the whole color table does<br>
indeed get copied over, I wrote a small script to remove the 'redundant<br>
color definitions. However, that did not help, the whole 'old' legend is<br>
still showing.  I had missed that -n flag, so I'll give that a try. Is<br>
there a similar option in ps.map to omit categories without label?<br>
<br>
  From a more conceptual point of view, is there any reason the whole<br>
category table is copied over to the new cats file?<br>
</blockquote>
<br></span>
Probably not. IIUC, this only happens when you have a formula of the form "new = old".<br>
<br>
An easy work around:<br>
<br>
r.category new  | r.category new rules=-<br>
<br>
The resulting cats file only contains the cats actually present and you can thus use d.legend -n to only show those.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>That is a very neat trick, thanks! <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
<br>
Moritz<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>