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

Moritz Lennert mlennert at club.worldonline.be
Wed Apr 8 07:58:44 EDT 2009


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


More information about the grass-user mailing list