[GRASS-user] displaying many thematic maps from one vector dataset

Hello all,

I am better at GRASS raster capabilities than with GRASS vector handling, so I am writing to get your help.

What I want to do is this:

  1. I will have one vector dataset of watersheds. Each record is a polygon, an individual watershed. There are, apart from the usual cat fields, 52 attribute columns. Each attribute column is modeled weekly snow depth.

  2. I need to automate the display and export to png of 52 thematic images - one for each week/column - keeping the color scheme constant throughout. Then all of the images will be packaged into a kml animation.

I know how to do the above starting from a stack of GRASS rasters, but am not quickly getting a handle on displaying GRASS vectors consistently. I’ve tried d.vect and d.vect.thematic. I havent tried d.thematic.area yet.

The main issues are that I dont know:

  • how to assign a constant color scheme to each map (that spans the min and max of all columns); i guess i was looking for something as simple as setting color rules like with raster data.

  • how to refer to each attribute column by column number in a loop (d.vect.thematic and d.thematic.area seem to need column name as attribute)

Any pointers would be greatly appreciated,
Vishal

Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org

On 03/04/09 00:23, Vishal Mehta wrote:

Hello all,

I am better at GRASS raster capabilities than with GRASS vector handling, so I am writing to get your help.

What I want to do is this:
1. I will have one vector dataset of watersheds. Each record is a polygon, an individual watershed. There are, apart from the usual cat fields, 52 attribute columns. Each attribute column is modeled weekly snow depth.

2. I need to automate the display and export to png of 52 thematic images - one for each week/column - keeping the color scheme constant throughout. Then all of the images will be packaged into a kml animation.

I know how to do the above starting from a stack of GRASS rasters, but am not quickly getting a handle on displaying GRASS vectors consistently. I've tried d.vect and d.vect.thematic. I havent tried d.thematic.area yet.

The main issues are that I dont know:
- how to assign a constant color scheme to each map (that spans the min and max of all columns); i guess i was looking for something as simple as setting color rules like with raster data.

If you want constant class breaks, i.e. the same class number and amplitudes linked to the same colors, then you can just manually provide breaks and colors in d.thematic.area.

- how to refer to each attribute column by column number in a loop (d.vect.thematic and d.thematic.area seem to need column name as attribute)

(assuming you are in a *nix environment with a shell):
for col in `v.info -c MapName`; do d.thematic.area .... column=$col; done
(note the backticks around the v.info command))

Moritz

A couple of strange behaviors with a test vector dataset whose columns are population projections every 5 years:
I ran the following script below but:

  1. I see it working ok on the x0 monitor; but the output png files are all blank…
  2. and i get messages while the script is running that include ‘segmentation fault’ but not on EVERY iteration of the loop…

---------------------script-------
#!/bin/bash
#generate 5yr interval thematic pngs of low series PPIC population projectiosn
yr=2010
while [ $yr -lt 2105 ] ; do

#actions here
echo "yr is $yr "

d.thematic.area map=CountyPop column=pc$yr breaks=20,40,60 colors=cyan,blue,yellow,red
d.out.file output=pop$yr format=png

yr=$((yr+5))
done
------------------------messages while running above script-----


yr is 2020
Segmentation fault
Saving display from Monitor: [x0] to <pop2020.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2025
Segmentation fault
Saving display from Monitor: [x0] to <pop2025.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2030
Segmentation fault
Saving display from Monitor: [x0] to <pop2030.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2035
Saving display from Monitor: [x0] to <pop2035.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2040
Saving display from Monitor: [x0] to <pop2040.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2045
Saving display from Monitor: [x0] to <pop2045.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.

On Thu, Apr 2, 2009 at 11:54 PM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 03/04/09 00:23, Vishal Mehta wrote:

Hello all,

I am better at GRASS raster capabilities than with GRASS vector handling, so I am writing to get your help.

What I want to do is this:

  1. I will have one vector dataset of watersheds. Each record is a polygon, an individual watershed. There are, apart from the usual cat fields, 52 attribute columns. Each attribute column is modeled weekly snow depth.

  2. I need to automate the display and export to png of 52 thematic images - one for each week/column - keeping the color scheme constant throughout. Then all of the images will be packaged into a kml animation.

I know how to do the above starting from a stack of GRASS rasters, but am not quickly getting a handle on displaying GRASS vectors consistently. I’ve tried d.vect and d.vect.thematic. I havent tried d.thematic.area yet.

The main issues are that I dont know:

  • how to assign a constant color scheme to each map (that spans the min and max of all columns); i guess i was looking for something as simple as setting color rules like with raster data.

If you want constant class breaks, i.e. the same class number and amplitudes linked to the same colors, then you can just manually provide breaks and colors in d.thematic.area.

  • how to refer to each attribute column by column number in a loop (d.vect.thematic and d.thematic.area seem to need column name as attribute)

(assuming you are in a *nix environment with a shell):
for col in [v.info](http://v.info) -c MapName; do d.thematic.area … column=$col; done
(note the backticks around the v.info command))

Moritz


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org

On 04/04/09 01:13, Vishal Mehta wrote:

A couple of strange behaviors with a test vector dataset whose columns are population projections every 5 years:
I ran the following script below but:
1. I see it working ok on the x0 monitor; but the output png files are all blank..
2. and i get messages while the script is running that include 'segmentation fault' but not on EVERY iteration of the loop..

I've seen this problem before, but not with fixed class breaks, but was not able to find its cause. The fact that you see it as well with fixed class breaks is already an interesting information that should help find out what is wrong. Note that this module has seen _very_ little testing up to now (if not none except mine).

And so you say that this only happens with PNG output (are you using d.mon PNG ?), but not on the x-monitors ?

Moritz

---------------------script-------
#!/bin/bash
#generate 5yr interval thematic pngs of low series PPIC population projectiosn
yr=2010
while [ $yr -lt 2105 ] ; do

#actions here
echo "yr is $yr "

d.thematic.area map=CountyPop column=pc$yr breaks=20,40,60 colors=cyan,blue,yellow,red
d.out.file output=pop$yr format=png
#
yr=$((yr+5))
done
------------------------messages while running above script-----

---
yr is 2020
Segmentation fault
Saving display from Monitor: [x0] to <pop2020.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2025
Segmentation fault
Saving display from Monitor: [x0] to <pop2025.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2030
Segmentation fault
Saving display from Monitor: [x0] to <pop2030.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2035
Saving display from Monitor: [x0] to <pop2035.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2040
Saving display from Monitor: [x0] to <pop2040.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
yr is 2045
Saving display from Monitor: [x0] to <pop2045.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small amount of time)
Image crop [523 x 480]
Done.
------

On Thu, Apr 2, 2009 at 11:54 PM, Moritz Lennert <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:

    On 03/04/09 00:23, Vishal Mehta wrote:

        Hello all,

        I am better at GRASS raster capabilities than with GRASS vector
        handling, so I am writing to get your help.

        What I want to do is this:
        1. I will have one vector dataset of watersheds. Each record is
        a polygon, an individual watershed. There are, apart from the
        usual cat fields, 52 attribute columns. Each attribute column is
        modeled weekly snow depth.

        2. I need to automate the display and export to png of 52
        thematic images - one for each week/column - keeping the color
        scheme constant throughout. Then all of the images will be
        packaged into a kml animation.

        I know how to do the above starting from a stack of GRASS
        rasters, but am not quickly getting a handle on displaying GRASS
        vectors consistently. I've tried d.vect and d.vect.thematic. I
        havent tried d.thematic.area yet.

        The main issues are that I dont know:
        - how to assign a constant color scheme to each map (that spans
        the min and max of all columns); i guess i was looking for
        something as simple as setting color rules like with raster data.

    If you want constant class breaks, i.e. the same class number and
    amplitudes linked to the same colors, then you can just manually
    provide breaks and colors in d.thematic.area.

         - how to refer to each attribute column by column number in a
        loop (d.vect.thematic and d.thematic.area seem to need column
        name as attribute)

    (assuming you are in a *nix environment with a shell):
    for col in `v.info <http://v.info> -c MapName`; do d.thematic.area
    .... column=$col; done
    (note the backticks around the v.info <http://v.info> command))

    Moritz

--
Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org <http://www.sei-us.org>

On 07/04/09 00:20, Vishal Mehta wrote:

An update: I got it to ALMOST work using the script below.

So this means you are not getting segfaults anymore ?

Am attaching the animated gif. But 2 issues remain:
1. I'd like to get a nice legend to display on top right of each display/png

Did you try the legendfile= parameter of d.thematic.area ? This creates an instructions file which you can feed into d.graph. Feedback on this is more than welcome and we can tweak that output according to your experience. The instructions file is pure text, so you can easily play around with it to find the right settings.

2. I am getting an error as follows for each iteration, even though the output png's are being exported
/yr is 2090
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: pc2090.png,
GRASS_WIDTH=4097, GRASS_HEIGHT=3775
Graphics driver [PNG] started
ERROR: Only X monitors are supported.

This comes from the use of d.out.file which is useless in your script. d.out.file takes all the commands used to display features on an X-monitor and displays them to a PNG. But when you use a PNG-"Monitor" you are already writing to a file. Just take out the call to d.out.file and you should get the same results without the error message.

Moritz

Monitor 'PNG' terminated
yr is 2100
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: pc2100.png,
GRASS_WIDTH=4097, GRASS_HEIGHT=3775
Graphics driver [PNG] started
ERROR: Only X monitors are supported.
Monitor 'PNG' terminated
/

I know you're busy, so whenever you can respond is totally fine- Vishal
-----SCRIPT FOLLOWS----
#!/bin/bash
#generate 5yr interval thematic pngs of low series PPIC population projections
# get current region settings from thematic map of interest
g.region vect=CountyPop2 # Store current environment
OLD_GRASS_WIDTH=$GRASS_WIDTH
OLD_GRASS_HEIGHT=$GRASS_HEIGHT
OLD_GRASS_PNGFILE=$GRASS_PNGFILE
OLD_GRASS_TRANSPARENT=$GRASS_TRANSPARENT
OLD_GRASS_TRUECOLOR=$GRASS_TRUECOLOR
LEGEND_WIDTH=500
LEGEND_HEIGHT=500
LEGEND_TEXT_COLOR=white
BACKGROUND_COLOR=black
# define the driver settings
export GRASS_WIDTH=`g.region -g | grep "cols" | cut -d= -f2`
export GRASS_HEIGHT=`g.region -g | grep "rows" | cut -d= -f2`
export GRASS_TRANSPARENT=FALSE ## if transparent the text overlaps in the animated gif created at the end
export GRASS_TRUECOLOR=TRUE ##
yr=2010
while [ $yr -lt 2105 ] ; do

echo "yr is $yr "
export GRASS_PNGFILE=pc$yr.png
d.mon start=PNG
d.mon select=PNG
d.thematic.area map=CountyPop2 column=pc$yr breaks=20,40,60 colors=cyan,blue,yellow,red
d.text -b text="$yr Population" at=50,90 size=4
d.out.file output=$GRASS_PNGFILE format=png
d.mon stop=PNG
#
if [ $yr -eq 2090 ]; then yr=$((yr+10)); else yr=$((yr+5)); fi;
done
#create an animated gif using Image Magick, delay 20/100 sec loop endless
convert -delay 20 -loop 0 *.png population.gif
------
---------------------------------------

On Mon, Apr 6, 2009 at 10:32 AM, Moritz Lennert <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:

    Thanks. I'll try to look into this as soon as I find the time (but
    am busy writing a report for a large research project right now...).
    Which version of GRASS are you using ?

    Moritz

    On 06/04/09 19:16, Vishal Mehta wrote:

        Moritz, thanks much for your interest in this.

        I'm attaching the shapefile that I used in these past
        conversations. Its California counties, in Latlong WGS84. column
        'pop2000' is 200 population. columns pc2005 to pc2100 are
        percentage changes from pop2000. note that pc2095 is missing
        (the data source is like that).

        All i'm trying to do is create a nice thematic map with
        consistent colors, and a nice legend; which i'll then convert
        into an animated kml. I've done this with rasters: i can share
        that with you as well.

        i've started a blog to put up some of this stuff:
        algoesalgo.wordpress.com <http://algoesalgo.wordpress.com>
        <http://algoesalgo.wordpress.com>

        Thanks again,
        Vishal

        On Mon, Apr 6, 2009 at 5:29 AM, Moritz Lennert
        <mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>
        <mailto:mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>>> wrote:

           Hi again,

           Would it be possible to send me your files offlist, so that I can
           try to reproduce the error ? Or you could see if you can
        reproduce
           it with one of the GRASS demo datasets ?

           Moritz

           On 04/04/09 01:13, Vishal Mehta wrote:

               A couple of strange behaviors with a test vector dataset
        whose
               columns are population projections every 5 years:
               I ran the following script below but:
               1. I see it working ok on the x0 monitor; but the output png
               files are all blank..
               2. and i get messages while the script is running that
        include
               'segmentation fault' but not on EVERY iteration of the loop..

               ---------------------script-------
               #!/bin/bash
               #generate 5yr interval thematic pngs of low series PPIC
               population projectiosn
               yr=2010
               while [ $yr -lt 2105 ] ; do

               #actions here
               echo "yr is $yr "

               d.thematic.area map=CountyPop column=pc$yr breaks=20,40,60
               colors=cyan,blue,yellow,red
               d.out.file output=pop$yr format=png
               #
               yr=$((yr+5))
               done
               ------------------------messages while running above
        script-----

               ---
               yr is 2020
               Segmentation fault
               Saving display from Monitor: [x0] to <pop2020.png>.
               Image size [640 x 480]
               Screen export complete. (writing the file may take a small
               amount of time)
               Image crop [523 x 480]
               Done.
               yr is 2025
               Segmentation fault
               Saving display from Monitor: [x0] to <pop2025.png>.
               Image size [640 x 480]
               Screen export complete. (writing the file may take a small
               amount of time)
               Image crop [523 x 480]
               Done.
               yr is 2030
               Segmentation fault
               Saving display from Monitor: [x0] to <pop2030.png>.
               Image size [640 x 480]
               Screen export complete. (writing the file may take a small
               amount of time)
               Image crop [523 x 480]
               Done.
               yr is 2035
               Saving display from Monitor: [x0] to <pop2035.png>.
               Image size [640 x 480]
               Screen export complete. (writing the file may take a small
               amount of time)
               Image crop [523 x 480]
               Done.
               yr is 2040
               Saving display from Monitor: [x0] to <pop2040.png>.
               Image size [640 x 480]
               Screen export complete. (writing the file may take a small
               amount of time)
               Image crop [523 x 480]
               Done.
               yr is 2045
               Saving display from Monitor: [x0] to <pop2045.png>.
               Image size [640 x 480]
               Screen export complete. (writing the file may take a small
               amount of time)
               Image crop [523 x 480]
               Done.
               ------

               On Thu, Apr 2, 2009 at 11:54 PM, Moritz Lennert
               <mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>
               <mailto:mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>>
               <mailto:mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>
               <mailto:mlennert@club.worldonline.be
        <mailto:mlennert@club.worldonline.be>>>> wrote:

                  On 03/04/09 00:23, Vishal Mehta wrote:

                      Hello all,

                      I am better at GRASS raster capabilities than with
        GRASS
               vector
                      handling, so I am writing to get your help.

                      What I want to do is this:
                      1. I will have one vector dataset of watersheds. Each
               record is
                      a polygon, an individual watershed. There are,
        apart from the
                      usual cat fields, 52 attribute columns. Each attribute
               column is
                      modeled weekly snow depth.

                      2. I need to automate the display and export to
        png of 52
                      thematic images - one for each week/column -
        keeping the
               color
                      scheme constant throughout. Then all of the images
        will be
                      packaged into a kml animation.

                      I know how to do the above starting from a stack
        of GRASS
                      rasters, but am not quickly getting a handle on
               displaying GRASS
                      vectors consistently. I've tried d.vect and
               d.vect.thematic. I
                      havent tried d.thematic.area yet.

                      The main issues are that I dont know:
                      - how to assign a constant color scheme to each map
               (that spans
                      the min and max of all columns); i guess i was
        looking for
                      something as simple as setting color rules like with
               raster data.

                  If you want constant class breaks, i.e. the same class
        number and
                  amplitudes linked to the same colors, then you can
        just manually
                  provide breaks and colors in d.thematic.area.

                       - how to refer to each attribute column by column
        number
               in a
                      loop (d.vect.thematic and d.thematic.area seem to
        need
               column
                      name as attribute)

                  (assuming you are in a *nix environment with a shell):
                  for col in `v.info <http://v.info> <http://v.info>
        <http://v.info> -c

               MapName`; do d.thematic.area
                  .... column=$col; done
                  (note the backticks around the v.info <http://v.info>
        <http://v.info>
               <http://v.info> command))

                  Moritz

               -- Vishal K. Mehta, PhD
               Scientist
               Stockholm Environment Institute - US
               133 D St Suite F
               Davis CA 95616
               www.sei-us.org <http://www.sei-us.org>
        <http://www.sei-us.org> <http://www.sei-us.org>

        -- Vishal K. Mehta, PhD
        Scientist
        Stockholm Environment Institute - US
        133 D St Suite F
        Davis CA 95616
        www.sei-us.org <http://www.sei-us.org> <http://www.sei-us.org>

--
Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org <http://www.sei-us.org>

------------------------------------------------------------------------

Hi Moritz,

hmmm…i’ll try it without the d.out.file command.

Regarding the segmentation faults: I switched to a different machine to do all this latter work. I havent tried the new scripts on the original machine (my laptop). Both are running 6.4svn.

Meanwhile, I’ve completed the script that creates an automated kml animation…although its a bit specific to my input vector fields…it is here:
http://algoesalgo.wordpress.com/2009/04/07/kml-animation-from-vector-polygons/

Regarding legends, I found that I had to play around way too much to get the legend right. And even then, there’s a yellow color that is not on the legend file, that shows up in the display anyway. So there’s still some strangeness there I think…but I need to check. After that I could perhaps make some recommendations on the legend stuff if that helps improve it…

Thanks again,
and everyone, please feel free to comment on the blog where I have put up the code
Vishal

On Tue, Apr 7, 2009 at 1:26 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 07/04/09 00:20, Vishal Mehta wrote:

An update: I got it to ALMOST work using the script below.

So this means you are not getting segfaults anymore ?

Am attaching the animated gif. But 2 issues remain:

  1. I’d like to get a nice legend to display on top right of each display/png

Did you try the legendfile= parameter of d.thematic.area ? This creates an instructions file which you can feed into d.graph. Feedback on this is more than welcome and we can tweak that output according to your experience. The instructions file is pure text, so you can easily play around with it to find the right settings.

  1. I am getting an error as follows for each iteration, even though the output png’s are being exported
    /yr is 2090
    PNG: GRASS_TRUECOLOR status: TRUE
    PNG: collecting to file: pc2090.png,
    GRASS_WIDTH=4097, GRASS_HEIGHT=3775
    Graphics driver [PNG] started
    ERROR: Only X monitors are supported.

This comes from the use of d.out.file which is useless in your script. d.out.file takes all the commands used to display features on an X-monitor and displays them to a PNG. But when you use a PNG-“Monitor” you are already writing to a file. Just take out the call to d.out.file and you should get the same results without the error message.

Moritz

Monitor ‘PNG’ terminated
yr is 2100
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: pc2100.png,
GRASS_WIDTH=4097, GRASS_HEIGHT=3775
Graphics driver [PNG] started
ERROR: Only X monitors are supported.
Monitor ‘PNG’ terminated
/

I know you’re busy, so whenever you can respond is totally fine- Vishal
-----SCRIPT FOLLOWS----
#!/bin/bash
#generate 5yr interval thematic pngs of low series PPIC population projections

get current region settings from thematic map of interest

g.region vect=CountyPop2 # Store current environment
OLD_GRASS_WIDTH=$GRASS_WIDTH
OLD_GRASS_HEIGHT=$GRASS_HEIGHT
OLD_GRASS_PNGFILE=$GRASS_PNGFILE
OLD_GRASS_TRANSPARENT=$GRASS_TRANSPARENT
OLD_GRASS_TRUECOLOR=$GRASS_TRUECOLOR
LEGEND_WIDTH=500
LEGEND_HEIGHT=500
LEGEND_TEXT_COLOR=white
BACKGROUND_COLOR=black

define the driver settings

export GRASS_WIDTH=g.region -g | grep "cols" | cut -d= -f2
export GRASS_HEIGHT=g.region -g | grep "rows" | cut -d= -f2
export GRASS_TRANSPARENT=FALSE ## if transparent the text overlaps in the animated gif created at the end
export GRASS_TRUECOLOR=TRUE ##
yr=2010
while [ $yr -lt 2105 ] ; do

echo “yr is $yr "
export GRASS_PNGFILE=pc$yr.png
d.mon start=PNG
d.mon select=PNG
d.thematic.area map=CountyPop2 column=pc$yr breaks=20,40,60 colors=cyan,blue,yellow,red
d.text -b text=”$yr Population" at=50,90 size=4
d.out.file output=$GRASS_PNGFILE format=png
d.mon stop=PNG

if [ $yr -eq 2090 ]; then yr=$((yr+10)); else yr=$((yr+5)); fi;
done
#create an animated gif using Image Magick, delay 20/100 sec loop endless
convert -delay 20 -loop 0 *.png population.gif


On Mon, Apr 6, 2009 at 10:32 AM, Moritz Lennert <mlennert@club.worldonline.be mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)> wrote:

Thanks. I’ll try to look into this as soon as I find the time (but
am busy writing a report for a large research project right now…).
Which version of GRASS are you using ?

Moritz

On 06/04/09 19:16, Vishal Mehta wrote:

Moritz, thanks much for your interest in this.

I’m attaching the shapefile that I used in these past
conversations. Its California counties, in Latlong WGS84. column
‘pop2000’ is 200 population. columns pc2005 to pc2100 are
percentage changes from pop2000. note that pc2095 is missing
(the data source is like that).

All i’m trying to do is create a nice thematic map with
consistent colors, and a nice legend; which i’ll then convert
into an animated kml. I’ve done this with rasters: i can share
that with you as well.

i’ve started a blog to put up some of this stuff:
algoesalgo.wordpress.com <http://algoesalgo.wordpress.com>
<http://algoesalgo.wordpress.com>

Thanks again,
Vishal

On Mon, Apr 6, 2009 at 5:29 AM, Moritz Lennert
<mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)

<mailto:mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)>> wrote:

Hi again,

Would it be possible to send me your files offlist, so that I can
try to reproduce the error ? Or you could see if you can
reproduce
it with one of the GRASS demo datasets ?

Moritz

On 04/04/09 01:13, Vishal Mehta wrote:

A couple of strange behaviors with a test vector dataset
whose
columns are population projections every 5 years:
I ran the following script below but:

  1. I see it working ok on the x0 monitor; but the output png
    files are all blank…
  2. and i get messages while the script is running that
    include
    ‘segmentation fault’ but not on EVERY iteration of the loop…

---------------------script-------
#!/bin/bash
#generate 5yr interval thematic pngs of low series PPIC
population projectiosn
yr=2010
while [ $yr -lt 2105 ] ; do

#actions here
echo "yr is $yr "

d.thematic.area map=CountyPop column=pc$yr breaks=20,40,60
colors=cyan,blue,yellow,red
d.out.file output=pop$yr format=png

yr=$((yr+5))
done
------------------------messages while running above
script-----


yr is 2020
Segmentation fault
Saving display from Monitor: [x0] to <pop2020.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small
amount of time)
Image crop [523 x 480]
Done.
yr is 2025
Segmentation fault
Saving display from Monitor: [x0] to <pop2025.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small
amount of time)
Image crop [523 x 480]
Done.
yr is 2030
Segmentation fault
Saving display from Monitor: [x0] to <pop2030.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small
amount of time)
Image crop [523 x 480]
Done.
yr is 2035
Saving display from Monitor: [x0] to <pop2035.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small
amount of time)
Image crop [523 x 480]
Done.
yr is 2040
Saving display from Monitor: [x0] to <pop2040.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small
amount of time)
Image crop [523 x 480]
Done.
yr is 2045
Saving display from Monitor: [x0] to <pop2045.png>.
Image size [640 x 480]
Screen export complete. (writing the file may take a small
amount of time)
Image crop [523 x 480]
Done.

On Thu, Apr 2, 2009 at 11:54 PM, Moritz Lennert
<mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)
<mailto:mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)>
<mailto:mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)
<mailto:mlennert@club.worldonline.be
mailto:[mlennert@club.worldonline.be](mailto:mlennert@club.worldonline.be)>>> wrote:

On 03/04/09 00:23, Vishal Mehta wrote:

Hello all,

I am better at GRASS raster capabilities than with
GRASS
vector
handling, so I am writing to get your help.

What I want to do is this:

  1. I will have one vector dataset of watersheds. Each
    record is
    a polygon, an individual watershed. There are,
    apart from the
    usual cat fields, 52 attribute columns. Each attribute
    column is
    modeled weekly snow depth.

  2. I need to automate the display and export to
    png of 52
    thematic images - one for each week/column -
    keeping the
    color
    scheme constant throughout. Then all of the images
    will be
    packaged into a kml animation.

I know how to do the above starting from a stack
of GRASS
rasters, but am not quickly getting a handle on
displaying GRASS
vectors consistently. I’ve tried d.vect and
d.vect.thematic. I
havent tried d.thematic.area yet.

The main issues are that I dont know:

  • how to assign a constant color scheme to each map
    (that spans
    the min and max of all columns); i guess i was
    looking for
    something as simple as setting color rules like with
    raster data.

If you want constant class breaks, i.e. the same class
number and
amplitudes linked to the same colors, then you can
just manually
provide breaks and colors in d.thematic.area.

  • how to refer to each attribute column by column
    number
    in a
    loop (d.vect.thematic and d.thematic.area seem to
    need
    column
    name as attribute)

(assuming you are in a *nix environment with a shell):
for col in `v.info <http://v.info> <http://v.info>
<http://v.info> -c

MapName`; do d.thematic.area
… column=$col; done
(note the backticks around the v.info <http://v.info>
<http://v.info>
<http://v.info> command))

Moritz

– Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org <http://www.sei-us.org>
<http://www.sei-us.org> <http://www.sei-us.org>

– Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org <http://www.sei-us.org> <http://www.sei-us.org>


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org <http://www.sei-us.org>



Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org

On 08/04/09 02:23, Vishal Mehta wrote:

Regarding the segmentation faults: I switched to a different machine
to do all this latter work. I havent tried the new scripts on the
original machine (my laptop). Both are running 6.4svn.

Weird. I can confirm segfaults in 6.5svn (I suppose that this is what
you mean by 6.4svn, i.e. the current 6.x development branch), but only
when using d.mon, not when using direct rendering
(GRASS_RENDER_IMMEDIATE=TRUE). Since I wrote this code on the base of
the grass7 tree, and then ported it back to 6.x, it is quite probable
that I forgot some adaptations needed for d.mons... (CC'ing to Glynn for
any pointer on where I should look).
Could you try with direct rendering on the machine where it segfaulted
with d.mons ?

Regarding legends, I found that I had to play around way too much to
get the legend right.

Could you tell me which were the major parts that needed adjustment from you ?

As you want to use the same legend for all maps, it is obviously easier
to create one legend file by hand and to call d.graph on that in each cycle of the loop.

However, I tweaked the source code (grass7 for now) just very slightly (changing text size and taking into account the case where the min value of the data is above the lowest break (or the max value below the highest break - see 2010-2030 max values in the example) and then ran the following script (using direct rendering as monitors don't exist anymore):

export GRASS_FONT=Vera
export GRASS_PNG_READ=TRUE

yr=2010
while [ $yr -lt 2105 ] ;
   do
     echo "yr is $yr "
     export GRASS_PNGFILE=pc$yr.png
     d.thematic.area map=CA column=pc$yr breaks=20,40,60\
    colors=cyan,yellow,red,blue leg=legfile
     d.text -b text="$yr Population" at=50,90 size=4
     d.graph in=legfile
     if [ $yr -eq 2090 ]
        then yr=$((yr+10))
        else yr=$((yr+5))
     fi
   done

You can see the resulting animated gif here:
http://geog-pc40.ulb.ac.be/popCA.gif

I don't find the legends too bad, but obviously it is difficult to create a one-size-fits-all solution for legends. I spent some time trying to find the right algorithm, but it is still very far from perfect. One thing I should probably add is a parameter for the placement of the legend in screen percents. Another is a detection mechanism to see how many significant decimals to keep (There should be some examples, notably in Hamish'es work, I just need to look at those...). I don't know, however, whether the d.graph solution is the best, so feedback is very welcome on that.

And even then, there's a yellow color that is not on the legend file,
that shows up in the display anyway.

Could you show an example of that ?

Thank you for your feedback so far. We really have to identify the cause of those segfaults...

Moritz

Hi Moritz,
Regarding legends with d.graph, these are the main issues where I found I needed to do too much of trial and error, some of which I think could probably be avoided/improved in a future version…

  1. the legend ends up with some strange additions beyond just the range of data: like what are those numbers after each range
    e.g. in the example below where did | 0 and | 5 come from? It would be nice to not have this automatically displayed.
    60 - 80 | 0
    80-100 | 5

  2. there could be a flag on d.graph, which allows the output to have a “< minbreak” and “> maxbreak” option, so that for cases like the one we are discussing, the legend does not keep changing based on different data ranges.

  3. size and position
    Here, I wanted to get a legend file separately, and save a legend png. To do this I had to play with the size and other parameters extensively to make the symbols and associated text match up. It would be great to be able to do the following with some flags, for the case where the legend alone is displayed:
    (i) set the overall size of the display within which the legend will be displayed
    (ii) set the position of the legend within the display with options like lowerleft, upperright, center, etc
    (iii) set the size of the legend as a fraction/percentage of the display.
    (iv) make the background transparent (or not)
    such that the above settings ‘automatically’ set up the symbol and corresponding text all properly lined up…

I am aware that if I was just better at this I could do it quickly enough…but the above functionality would make it easier for less-than-expert people like myself, who try to use open-source as much as possible despite the handicap of having been groomed on Windows…

I will write back when i’ve had a chance to look up the segfaults on my laptop…

And oh, the mismatch of color between display and legend was entirely my fault - i was displaying with one set of colors but had tweaked the legend file separately with a different set of colors…

Thanks for all your help,
Vishal

On Wed, Apr 8, 2009 at 4:58 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 08/04/09 02:23, Vishal Mehta wrote:

Regarding the segmentation faults: I switched to a different machine
to do all this latter work. I havent tried the new scripts on the
original machine (my laptop). Both are running 6.4svn.

Weird. I can confirm segfaults in 6.5svn (I suppose that this is what
you mean by 6.4svn, i.e. the current 6.x development branch), but only
when using d.mon, not when using direct rendering
(GRASS_RENDER_IMMEDIATE=TRUE). Since I wrote this code on the base of
the grass7 tree, and then ported it back to 6.x, it is quite probable
that I forgot some adaptations needed for d.mons… (CC’ing to Glynn for
any pointer on where I should look).
Could you try with direct rendering on the machine where it segfaulted
with d.mons ?

Regarding legends, I found that I had to play around way too much to
get the legend right.

Could you tell me which were the major parts that needed adjustment from you ?

As you want to use the same legend for all maps, it is obviously easier
to create one legend file by hand and to call d.graph on that in each cycle of the loop.

However, I tweaked the source code (grass7 for now) just very slightly (changing text size and taking into account the case where the min value of the data is above the lowest break (or the max value below the highest break - see 2010-2030 max values in the example) and then ran the following script (using direct rendering as monitors don’t exist anymore):

export GRASS_FONT=Vera
export GRASS_PNG_READ=TRUE

yr=2010
while [ $yr -lt 2105 ] ;
do
echo "yr is $yr "
export GRASS_PNGFILE=pc$yr.png

d.thematic.area map=CA column=pc$yr breaks=20,40,60
colors=cyan,yellow,red,blue leg=legfile

d.text -b text=“$yr Population” at=50,90 size=4

d.graph in=legfile
if [ $yr -eq 2090 ]
then yr=$((yr+10))
else yr=$((yr+5))
fi
done

You can see the resulting animated gif here:
http://geog-pc40.ulb.ac.be/popCA.gif

I don’t find the legends too bad, but obviously it is difficult to create a one-size-fits-all solution for legends. I spent some time trying to find the right algorithm, but it is still very far from perfect. One thing I should probably add is a parameter for the placement of the legend in screen percents. Another is a detection mechanism to see how many significant decimals to keep (There should be some examples, notably in Hamish’es work, I just need to look at those…). I don’t know, however, whether the d.graph solution is the best, so feedback is very welcome on that.

And even then, there’s a yellow color that is not on the legend file,
that shows up in the display anyway.

Could you show an example of that ?

Thank you for your feedback so far. We really have to identify the cause of those segfaults…

Moritz


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org

And one more for the wish list on legends:

  • a flag to strip off decimal places if the data happens to be float…

On Wed, Apr 8, 2009 at 9:48 AM, Vishal Mehta <vishalm1975@gmail.com> wrote:

Hi Moritz,
Regarding legends with d.graph, these are the main issues where I found I needed to do too much of trial and error, some of which I think could probably be avoided/improved in a future version…

  1. the legend ends up with some strange additions beyond just the range of data: like what are those numbers after each range
    e.g. in the example below where did | 0 and | 5 come from? It would be nice to not have this automatically displayed.
    60 - 80 | 0
    80-100 | 5

  2. there could be a flag on d.graph, which allows the output to have a “< minbreak” and “> maxbreak” option, so that for cases like the one we are discussing, the legend does not keep changing based on different data ranges.

  3. size and position
    Here, I wanted to get a legend file separately, and save a legend png. To do this I had to play with the size and other parameters extensively to make the symbols and associated text match up. It would be great to be able to do the following with some flags, for the case where the legend alone is displayed:
    (i) set the overall size of the display within which the legend will be displayed
    (ii) set the position of the legend within the display with options like lowerleft, upperright, center, etc
    (iii) set the size of the legend as a fraction/percentage of the display.
    (iv) make the background transparent (or not)
    such that the above settings ‘automatically’ set up the symbol and corresponding text all properly lined up…

I am aware that if I was just better at this I could do it quickly enough…but the above functionality would make it easier for less-than-expert people like myself, who try to use open-source as much as possible despite the handicap of having been groomed on Windows…

I will write back when i’ve had a chance to look up the segfaults on my laptop…

And oh, the mismatch of color between display and legend was entirely my fault - i was displaying with one set of colors but had tweaked the legend file separately with a different set of colors…

Thanks for all your help,
Vishal

On Wed, Apr 8, 2009 at 4:58 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 08/04/09 02:23, Vishal Mehta wrote:

Regarding the segmentation faults: I switched to a different machine
to do all this latter work. I havent tried the new scripts on the
original machine (my laptop). Both are running 6.4svn.

Weird. I can confirm segfaults in 6.5svn (I suppose that this is what
you mean by 6.4svn, i.e. the current 6.x development branch), but only
when using d.mon, not when using direct rendering
(GRASS_RENDER_IMMEDIATE=TRUE). Since I wrote this code on the base of
the grass7 tree, and then ported it back to 6.x, it is quite probable
that I forgot some adaptations needed for d.mons… (CC’ing to Glynn for
any pointer on where I should look).
Could you try with direct rendering on the machine where it segfaulted
with d.mons ?

Regarding legends, I found that I had to play around way too much to
get the legend right.

Could you tell me which were the major parts that needed adjustment from you ?

As you want to use the same legend for all maps, it is obviously easier
to create one legend file by hand and to call d.graph on that in each cycle of the loop.

However, I tweaked the source code (grass7 for now) just very slightly (changing text size and taking into account the case where the min value of the data is above the lowest break (or the max value below the highest break - see 2010-2030 max values in the example) and then ran the following script (using direct rendering as monitors don’t exist anymore):

export GRASS_FONT=Vera
export GRASS_PNG_READ=TRUE

yr=2010
while [ $yr -lt 2105 ] ;
do
echo "yr is $yr "
export GRASS_PNGFILE=pc$yr.png

d.thematic.area map=CA column=pc$yr breaks=20,40,60
colors=cyan,yellow,red,blue leg=legfile

d.text -b text=“$yr Population” at=50,90 size=4

d.graph in=legfile
if [ $yr -eq 2090 ]
then yr=$((yr+10))
else yr=$((yr+5))
fi
done

You can see the resulting animated gif here:
http://geog-pc40.ulb.ac.be/popCA.gif

I don’t find the legends too bad, but obviously it is difficult to create a one-size-fits-all solution for legends. I spent some time trying to find the right algorithm, but it is still very far from perfect. One thing I should probably add is a parameter for the placement of the legend in screen percents. Another is a detection mechanism to see how many significant decimals to keep (There should be some examples, notably in Hamish’es work, I just need to look at those…). I don’t know, however, whether the d.graph solution is the best, so feedback is very welcome on that.

And even then, there’s a yellow color that is not on the legend file,
that shows up in the display anyway.

Could you show an example of that ?

Thank you for your feedback so far. We really have to identify the cause of those segfaults…

Moritz


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org

On 08/04/09 18:48, Vishal Mehta wrote:

Hi Moritz,
Regarding legends with d.graph, these are the main issues where I found I needed to do too much of trial and error, some of which I think could probably be avoided/improved in a future version...

1. the legend ends up with some strange additions beyond just the range of data: like what are those numbers after each range
e.g. in the example below where did | 0 and | 5 come from? It would be nice to not have this automatically displayed.
60 - 80 | 0
80-100 | 5

This comes from my scientific background which says that a legend should include information about the frequencies of observations in each class. This is what these numbers show. But I agree that this should probably be optional.

2. there could be a flag on d.graph, which allows the output to have a "< minbreak" and "> maxbreak" option, so that for cases like the one we are discussing, the legend does not keep changing based on different data ranges.

d.graph is "just" a drawing module. Any such flags will have to go into d.thematic.area, or a specific d.thematic.legend module, but yes, sounds good.

3. size and position
Here, I wanted to get a legend file separately, and save a legend png. To do this I had to play with the size and other parameters extensively to make the symbols and associated text match up. It would be great to be able to do the following with some flags, for the case where the legend alone is displayed:
(i) set the overall size of the display within which the legend will be displayed
(ii) set the position of the legend within the display with options like lowerleft, upperright, center, etc

positioning in d.graph is in percentage, so the size of the display should not make a difference for the relative localisation.

(iii) set the size of the legend as a fraction/percentage of the display.

Size of text is in percentage, but size of symbols aren't. But I guess you mean the legend as a whole. There should probably be some way to calculate the size of the different elements given a general value from the user. Again, this would have to be a parameter for d.thematic.*.

(iv) make the background transparent (or not)

At this stage the background is transparent, but I could add a flag to allow non-transparent (you can do it yourself by just drawing a white rectangle underneath).

such that the above settings 'automatically' set up the symbol and corresponding text all properly lined up..

d.graph does not have any "alignment" feature, you have to work with the percentage positioning, but one problem (I think) is that different fonts have different sizes, so a same size but different font will lead to different alignments.

I am aware that if I was just better at this I could do it quickly enough..but the above functionality would make it easier for less-than-expert people like myself, who try to use open-source as much as possible despite the handicap of having been groomed on Windows...

Cartography is currently one of the weak points of GRASS, although you can't beat it for automatic cartography as you are doing (well, gmt can do that, but don't know about thematic cartography in gmt).

Thank you for the extensive feedback, though. I get the feeling that there should be some d.thematic.legend module which uses the output of the -l flag of d.thematic.area to then create a nice-looking legend.

You might also want to have a look at ps.map which allows some more sophisticated cartography and offers an automatic legend.

Moritz

Hi Moritz, all,

In displaying this kind thematic vector data, how can I assign a transparent color to the value zero? (zero is Not the null value of the GRASS vector dataset)

Thanks,
Vishal

On Wed, Apr 8, 2009 at 10:24 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 08/04/09 18:48, Vishal Mehta wrote:

Hi Moritz,
Regarding legends with d.graph, these are the main issues where I found I needed to do too much of trial and error, some of which I think could probably be avoided/improved in a future version…

  1. the legend ends up with some strange additions beyond just the range of data: like what are those numbers after each range
    e.g. in the example below where did | 0 and | 5 come from? It would be nice to not have this automatically displayed.
    60 - 80 | 0
    80-100 | 5

This comes from my scientific background which says that a legend should include information about the frequencies of observations in each class. This is what these numbers show. But I agree that this should probably be optional.

  1. there could be a flag on d.graph, which allows the output to have a “< minbreak” and “> maxbreak” option, so that for cases like the one we are discussing, the legend does not keep changing based on different data ranges.

d.graph is “just” a drawing module. Any such flags will have to go into d.thematic.area, or a specific d.thematic.legend module, but yes, sounds good.

  1. size and position
    Here, I wanted to get a legend file separately, and save a legend png. To do this I had to play with the size and other parameters extensively to make the symbols and associated text match up. It would be great to be able to do the following with some flags, for the case where the legend alone is displayed:
    (i) set the overall size of the display within which the legend will be displayed
    (ii) set the position of the legend within the display with options like lowerleft, upperright, center, etc

positioning in d.graph is in percentage, so the size of the display should not make a difference for the relative localisation.

(iii) set the size of the legend as a fraction/percentage of the display.

Size of text is in percentage, but size of symbols aren’t. But I guess you mean the legend as a whole. There should probably be some way to calculate the size of the different elements given a general value from the user. Again, this would have to be a parameter for d.thematic.*.

(iv) make the background transparent (or not)

At this stage the background is transparent, but I could add a flag to allow non-transparent (you can do it yourself by just drawing a white rectangle underneath).

such that the above settings ‘automatically’ set up the symbol and corresponding text all properly lined up…

d.graph does not have any “alignment” feature, you have to work with the percentage positioning, but one problem (I think) is that different fonts have different sizes, so a same size but different font will lead to different alignments.

I am aware that if I was just better at this I could do it quickly enough…but the above functionality would make it easier for less-than-expert people like myself, who try to use open-source as much as possible despite the handicap of having been groomed on Windows…

Cartography is currently one of the weak points of GRASS, although you can’t beat it for automatic cartography as you are doing (well, gmt can do that, but don’t know about thematic cartography in gmt).

Thank you for the extensive feedback, though. I get the feeling that there should be some d.thematic.legend module which uses the output of the -l flag of d.thematic.area to then create a nice-looking legend.

You might also want to have a look at ps.map which allows some more sophisticated cartography and offers an automatic legend.

Moritz


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org

On 16/04/09 21:54, Vishal Mehta wrote:

Hi Moritz, all,

In displaying this kind thematic vector data, how can I assign a transparent color to the value zero? (zero is Not the null value of the GRASS vector dataset)

The easiest is probably to use a where= clause such as

where="value<>0"

Moritz

Thanks,
Vishal

On Wed, Apr 8, 2009 at 10:24 AM, Moritz Lennert <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:

    On 08/04/09 18:48, Vishal Mehta wrote:

        Hi Moritz,
        Regarding legends with d.graph, these are the main issues where
        I found I needed to do too much of trial and error, some of
        which I think could probably be avoided/improved in a future
        version...

        1. the legend ends up with some strange additions beyond just
        the range of data: like what are those numbers after each range
        e.g. in the example below where did | 0 and | 5 come from? It
        would be nice to not have this automatically displayed.
        60 - 80 | 0
        80-100 | 5

    This comes from my scientific background which says that a legend
    should include information about the frequencies of observations in
    each class. This is what these numbers show. But I agree that this
    should probably be optional.

        2. there could be a flag on d.graph, which allows the output to
        have a "< minbreak" and "> maxbreak" option, so that for cases
        like the one we are discussing, the legend does not keep
        changing based on different data ranges.

    d.graph is "just" a drawing module. Any such flags will have to go
    into d.thematic.area, or a specific d.thematic.legend module, but
    yes, sounds good.

        3. size and position
        Here, I wanted to get a legend file separately, and save a
        legend png. To do this I had to play with the size and other
        parameters extensively to make the symbols and associated text
        match up. It would be great to be able to do the following with
        some flags, for the case where the legend alone is displayed:
        (i) set the overall size of the display within which the legend
        will be displayed
        (ii) set the position of the legend within the display with
        options like lowerleft, upperright, center, etc

    positioning in d.graph is in percentage, so the size of the display
    should not make a difference for the relative localisation.

        (iii) set the size of the legend as a fraction/percentage of the
        display.

    Size of text is in percentage, but size of symbols aren't. But I
    guess you mean the legend as a whole. There should probably be some
    way to calculate the size of the different elements given a general
    value from the user. Again, this would have to be a parameter for
    d.thematic.*.

        (iv) make the background transparent (or not)

    At this stage the background is transparent, but I could add a flag
    to allow non-transparent (you can do it yourself by just drawing a
    white rectangle underneath).

        such that the above settings 'automatically' set up the symbol
        and corresponding text all properly lined up..

    d.graph does not have any "alignment" feature, you have to work with
    the percentage positioning, but one problem (I think) is that
    different fonts have different sizes, so a same size but different
    font will lead to different alignments.

        I am aware that if I was just better at this I could do it
        quickly enough..but the above functionality would make it easier
        for less-than-expert people like myself, who try to use
        open-source as much as possible despite the handicap of having
        been groomed on Windows...

    Cartography is currently one of the weak points of GRASS, although
    you can't beat it for automatic cartography as you are doing (well,
    gmt can do that, but don't know about thematic cartography in gmt).

    Thank you for the extensive feedback, though. I get the feeling that
    there should be some d.thematic.legend module which uses the output
    of the -l flag of d.thematic.area to then create a nice-looking legend.

    You might also want to have a look at ps.map which allows some more
    sophisticated cartography and offers an automatic legend.

    Moritz

--
Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org <http://www.sei-us.org>

Hi Moritz,
all

I’m still not able to refer to a column number to display the thematic layer …only to column names…am i missing something like back-ticks and so on…?

Vishal

  • how to refer to each attribute column by column number in a loop (d.vect.thematic and d.thematic.area seem to need column name as attribute)

(assuming you are in a *nix environment with a shell):
for col in [v.info](http://v.info) -c MapName; do d.thematic.area … column=$col; done
(note the backticks around the v.info command))

Moritz


Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org