[GRASS-dev] Where is the GRASS legend file?

Vaclav Petras wenzeslaus at gmail.com
Thu Jul 20 19:16:48 PDT 2023


Hi Michael,

On Thu, 20 Jul 2023 at 18:14, Michael Barton <Michael.Barton at asu.edu> wrote:

> According to the d.legend.vect manual, I should have a legend file
> somewhere for all vectors. Here is what it says in notes:
>
> "Module d.legend.vect draws vector legend based on legend file defined in
> shell environment variable GRASS_LEGEND_FILE. This file is automatically
> created and updated whenever d.vect command is used. User can create custom
> legend file and then use export GRASS_LEGEND_FILE=path/to/file in shell.
> GRASS GUI and MONITORS create the legend file automatically. By default the
> legend file is stored in grassdata/location/mapset/.tmp/user directory (in
> case of d.mon deeper in /monitor_name directory)."
>

It seems the documentation is wrong. Perhaps documenting an earlier state.

GUI puts all these files in a subdirectory of /tmp/. `find /tmp/ -name
"legend.txt"` reveals that.

The monitors (d.mon) put that indeed in the mapset .tmp directory, but it
is a longer path than the documentation suggests, for wx0, I have:

~/grassdata/nc_spm_08_grass7/mapset_name/.tmp/node_name/MONITORS/wx0/leg


> As a test, I made a vector areas file out of the landclass96_28 raster in
> the North Carolina demo dataset. I set the vector color table to match the
> original raster. That works fine. Now I'd like to make a legend out of
> this. But I can't find the file that is supposed to be generated
> automatically to use or examine.
>

If you just want to use it with d.legend.vect, there is actually nothing to
do. d.legend.vect will pick it up automatically just like in the example in
the documentation. On the other hand, if you want to modify it by hand, use
input and output parameters of d.legend.vect.

The whole GRASS_LEGEND_FILE part is hidden from the user and you use it
(only?) if you are using the other environment variables for rendering.
Perhaps this needs to be emphasized in the documentation. (?)


> It is not in  grassdata/location/mapset/.tmp/user directory
> /Users/cmbarton/Dropbox\
> \(ASU\)/GRASS_dropbox/grassdata_dropbox/nc_spm_08_grass7/spatialtech2023/.tmp
> This directory contains no files and only one empty folder ("OKED3863").
>
> The environmental variable GRASS_LEGEND_FILE appears to be empty
>

The variable is set internally for the commands which do the rendering, so
you cannot get to it otherwise. If you set up things yourself in the shell
or in Python, then you would also set up the variable.


> So can anyone help me find this missing file?
>

I hope this clarifies that. Please suggest edits to the documentation.

BTW, grass.jupyter.Map is used in the same way, i.e., no direct handling of
GRASS_LEGEND_FILE, just d.legend.vect (d_legend_vect). If you are
interested, the implementation is easier to digest than the wxGUI code:

https://github.com/OSGeo/grass/blob/main/python/grass/jupyter/map.py#L90

Best,
Vaclav


>
> Michael
>
>
> _____________________________
>
> C. Michael Barton
> Associate Director, School of Complex Adaptive Systems (
> https://scas.asu.edu)
> Professor, School of Human Evolution & Social Change (
> https://shesc.asu.edu)
> Director, Center for Social Dynamics & Complexity (
> https://complexity.asu.edu)
> Arizona State University
> Tempe, AZ 85287-2701
> USA
>
> Executive Director, Open Modeling Foundation (
> https://openmodelingfoundation.github.io)
> Director, Network for Computational Modeling in Social & Ecological
> Sciences (https://comses.net)
>
> personal website: http://www.public.asu.edu/~cmbarton
>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20230720/c8a7aadf/attachment-0001.htm>


More information about the grass-dev mailing list