SV: [GRASS-user] Vector map text legend

Hamish hamish_b at yahoo.com
Tue Apr 5 03:29:33 EDT 2011


Hamish:
>> "the way to do this is to use
>> r.category to add category labels to each of your four
>> raster category numbers, then use d.legends's -c flag to
>> hide the value of the number, so only the label is
>> displayed."

Martin Album Ytre-Eide wrote:
> This was exactly what I was looking for. This solves many
> of my legend issues. Thanks a lot.

glad to hear it.

> A follow up question is: Would this be a good way to deal
> with logarithmic values in a legend? 

d.legend use=, but the version from GRASS 6.5 or 7, with Dylan's verbatim patch.
 
> -I convert rasters to have logarithmic values with
> r.mapcal: map = log(old_map,10)
> -This gives me a nice map with a nice legend. One could use
> r.colors -g (logarithmic scaling), but this messes up the
> legend - the legend is still linear- and it does not look
> good.
> -The problem is(my way of doing things) that the category
> numbers are log values as well(say 1-3-5 insted of
> 10-1000-100000), which there is noting wrong with, it is
> just not that easy to read. 

use= will draw at whatever levels you give it; I plan to backport
the (anti-)rounding patch for 6.4.2, ie after some time of live
testing. see https://trac.osgeo.org/grass/ticket/1147
feedback welcome.

> So, is it a good idea to add category labels to all values
> (or a range of values) x - 10^x ( so for 1, I add 10 and so
> fort) or is it a better way to do this as well?

It's a matter of taste, but personally I am not a fan of band
rendering- where you (as a human) decide to arbitrarily assign
the category breaks can have a most remarkable(!) effect on how
the map is interpreted by other humans. See "how to lie with
statistics", "how to lie with maps", and other related books &
articles. You'll probably be most convinced by your own data one
day, when you pop one of your own insights after a new rendering.
In nature such thresholds are not so clearly defined. To aid the
viewer of a figure my favourite method is a continuous color
gradation + overlaid contour lines.


but anyway, ... the easiest way to display classes from raster
data in GRASS is to make a r.colors rule set like:

0% blue
25% blue
25% cyan
50% cyan
50% yellow
75% yellow
75% red
100% red

then r.category 'a - b' classes + d.legend use= can work.
hint for the above: remember that if you are careful the map
displayed and the legend displayed can actually be for two
different maps (one of which being a dummy which just exists
for making the legend).

(note to self- verify that GRASS 7 doesn't optimize that step
functionality away)


I think Arc & copycats use class breaks so much in their legends
simply as a matter of the vector-feature heritage of that
software; histogram classes make more sense if you start with
a number of sparse data points. In raster maps (traditionally
GRASS's strong point) it is more a case of continuous gradations.
shrug; just a small theory.


hope it helps,
Hamish



More information about the grass-user mailing list