SV: [GRASS-user] Vector map text legend

Martin Album Ytre-Eide Martin.Album.Ytre-Eide at nrpa.no
Mon Apr 4 06:53:30 EDT 2011


"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."

This was exactly what I was looking for. This solves many of my legend issues. Thanks a lot.

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

-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. 

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?

Martin


 


-----Opprinnelig melding-----
Fra: Hamish [mailto:hamish_b at yahoo.com] 
Sendt: 2. april 2011 08:56
Til: grass-user at lists.osgeo.org
Kopi: Martin Album Ytre-Eide
Emne: Re: [GRASS-user] Vector map text legend

Martin Album Ytre-Eide wrote:
> I am looking for a way to make a legend to some vector area maps. The 
> maps contain four different types of areas and are given different 
> names.
> 
> I have made a python script running d.mon, d.vect etc. with the png 
> driver producing about 14 png files, which then is used to create a 
> gif file.
>
> A way to create a vector legend is to do v.to.rast and use the 
> d.legend from the "dummy" rast -

(e.g. the v.colors script)

> however, I don't see how you can get a legend with text in this way? I 
> don't think you can since raster should have numerical values. You 
> could make a legend without category numbers and try to add the text 
> with d.text, but I don't know if that's a good way of doing things.

d.text would work, but it's a lot of trouble to get it right.

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.

fwiw an approach to avoid the intermediary raster step is outlined in wish #89.


> Then there is ps.map which solves this in a nice way - the problem is 
> - I would like to keep the png format. I could just make the legend 
> with ps.map - and add it to my png files with some image tools in 
> python, but I am unsure of the result is worth the effort.

It is possible, actually I used this with html2latex's pstoimg program quite recently to add a custom legend in a journal figure created by other software, as it does such a nice job. Note there are some customizations I need to finish/clean up which make that a bit nicer to use (e.g. legend entries ordered by column before row), and the ps.output addon has made an entirely new vector legend tool.

pstoimg example:
  http://grass.osgeo.org/wiki/Ps.map_scripts#Converting_PostScript_to_PNG


good luck,
Hamish



More information about the grass-user mailing list