[GRASS-user] displaying many thematic maps from one vector
dataset
Vishal Mehta
vishalm1975 at gmail.com
Tue Apr 7 20:23:26 EDT 2009
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 at 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.
>
> 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 at club.worldonline.be <mailto:mlennert at 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 at club.worldonline.be
>> <mailto:mlennert at club.worldonline.be>
>> <mailto:mlennert at club.worldonline.be
>> <mailto:mlennert at 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 at club.worldonline.be
>> <mailto:mlennert at club.worldonline.be>
>> <mailto:mlennert at club.worldonline.be
>> <mailto:mlennert at club.worldonline.be>>
>> <mailto:mlennert at club.worldonline.be
>> <mailto:mlennert at club.worldonline.be>
>> <mailto:mlennert at club.worldonline.be
>> <mailto:mlennert at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20090407/f9d672d1/attachment-0001.html
More information about the grass-user
mailing list