[GRASSLIST:496] Re: creating legend file for vector map

Moritz Lennert mlennert at club.worldonline.be
Tue Jun 24 10:35:42 EDT 2003


Keith J. Forbes said:
> On Friday 20 June 2003 17:15, Moritz Lennert wrote:
>> ML  Keith J. Forbes said:
>> ML  >
>> ML  >
>> ML  >
>> ML  > On Friday 20 June 2003 15:00, Keith J. Forbes wrote:
>> ML  >> KJ  Hi. I have imported using m.in.e00 e00 vector maps, and all
>> the
>> ML  >> associated KJ  categories have been imported and are stored in
>> the
>> ML  >> dig_cats
>> ML  >> directory. I KJ  would like to create a legend file (preferably
>> have
>> ML  >> GRASS
>> ML  >> do this for me) so KJ  that each category can de displayed with a
>> ML  >> different
>> ML  >> color and an KJ  accompanying legend.
>> ML  >> KJ
>> ML  >> KJ  The only info I have found so far is that I would have to
>> create
>> ML  >> this
>> ML  >> bt hand KJ  using the category files, which seems to be quite
>> ML  >> cumbersome.
>> ML  >> KJ
>> ML  >> KJ  I hope there is another way to do this, and would appreciate
>> any
>> ML  >> help.
>> ML  >> Thanks KJ  in advance for your indulgence of a GRASS newbie.
>> ML  >> KJ
>> ML  >> KJ
>> ML  >> KJ
>> ML  >
>> ML  >
>> ML  >
>> ML  > Well, I ended up doing this the hard way (by hand) by creating a
>> legend ML  > file
>> ML  > (table like this without header row of course) to use with
>> d.vect.area: ML  >
>> ML  > Cat. RGB
>> ML  > 1  xxx xxx xxx
>> ML  > 2 xxx xxy xxy
>> ML  > and so on
>> ML  >
>> ML  > which worked fine after I got a RGB pallette from the web
>> ML  >
>> ML  > Now, I would like to display a legend along with the colored map
>> matching ML  > the
>> ML  > category labels to the colors.
>> ML  >
>> ML  > Help!!!
>> ML  >
>> ML
>> ML  Well, the only way I know how you can do this is to create a new
>> vector
>> ML  file (in v.digit, for example) with as many areas (for example
>> rectangles) ML  as you have categories, label each area with one of the
>> category numbers ML  and apply your legend file to this new vector map.
>> ML
>> ML  If you create your legend file in v.digit, you can use the Customize
>> ->
>> ML  Select An Overlay vector Map option to overlay your base vector map
>> in
>> ML  order to place the legend at a convenient spot in relation to your
>> base
>> ML  vector map.
>> ML
>> ML  Moritz
>> ML
>> ML
>
> Thanks Moritz.
>
> I have over 40 categories, and I tried digitizing a couple of rectangles
> and
> found that the process of creating rectangles without leaks, labelling
> them,
> etc. is quite cumbersome. There must be another way to get GRASS to use
> the
> legend file I made by hand (2 columns of text, one with categories, and
> another with RGB values) to make a legend box?
>
> Can anyone help with this???  Thanks in advance.
>

I see two possibilities:

- Either you do what someone else already suggested, i.e. transforming
your vector map into raster and using d.legend (this is the classical
GRASS way).

- Or you can try v.in.poly to automatically create polygons (squares if
you use segments=4; play around with the radius parameter to find correct
size). With a little script you should be able to write an input file
containing coordinates for easily spaced squares (depending on your
projection and region), category number and description. If you apply your
color legend to these polygons you should have a legend.
However, I not too sure about the best way to place the text descriptions.
d.vect.labels unfortunately does not allow changing the offset of the
text, so it is placed directly onto the polygon. Other modules either only
work interactively, or you don't allow you to give a file containing the
text and coordinates for all labels. Maybe someone else can help you with
this.

Moritz




More information about the grass-user mailing list