grass-windows Digest, Vol 64, Issue 2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

grass-windows Digest, Vol 64, Issue 2

grass-windows-request
Send grass-windows mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.osgeo.org/mailman/listinfo/grass-windows
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of grass-windows digest..."


Today's Topics:

   1. grass_width, grass_heigt and grass_pngfile (Liu, Huili)
   2. Re: grass_width, grass_heigt and grass_pngfile (Markus Neteler)
   3. Re: grass_width, grass_heigt and grass_pngfile (Glynn Clements)


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

Message: 1
Date: Fri, 2 Mar 2012 20:27:46 +0000
From: "Liu, Huili" <[hidden email]>
Subject: [GRASS-windows] grass_width, grass_heigt and grass_pngfile
To: "[hidden email]" <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="us-ascii"

Hi grass experts,

I am trying to create a python script to get an image file as below:

#get_img.py
import os.path
import sys # the sys module [2]
from grass.script import core as grass # the core module [3]
def main():
    grass.run_command('d.his i=elevation_shade h=elevation')

if __name__ == "__main__": # this allows the script to be used as a module in other scripts or as a standalone script
    #options, flags = grass.parser() #
    sys.exit(main())

But I got the default image file name,  map.png with GRASS_WIDTH=640 and GRASS_HEIGHT=480.
Is there any way for me to setup  width and height and my image file name in grass.run_command?
I searched the doc for a while but I still can not get a correct syntax.

Thanks for an advance!
Willie



The information contained in this communication is intended for the use
of the designated recipients named above. If the reader of this
communication is not the intended recipient, you are hereby notified
that you have received this communication in error, and that any review,
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please
notify The Associated Press immediately by telephone at +1-212-621-1898
and delete this email. Thank you.
[IP_US_DISC]

msk dccc60c6d2c3a6438f0cf467d9a4938
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-windows/attachments/20120302/c26565fa/attachment-0001.html

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

Message: 2
Date: Sat, 3 Mar 2012 06:19:44 +0100
From: Markus Neteler <[hidden email]>
Subject: Re: [GRASS-windows] grass_width, grass_heigt and
        grass_pngfile
To: "Liu, Huili" <[hidden email]>
Cc: "[hidden email]" <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1

Hi Willie,

On Fri, Mar 2, 2012 at 9:27 PM, Liu, Huili <[hidden email]> wrote:
>
> I am trying to create a python script to get an image file as below:
>
...
>
> But I got the default image file name,  map.png with GRASS_WIDTH=640 and
> GRASS_HEIGHT=480.
>
> Is there any way for me to setup  width and height and my image file name in
> grass.run_command?

You need to set these two environment variables

    GRASS_WIDTH=xxx
    the width of the image map (default is 640).

    GRASS_HEIGHT=yyy
    the height of the image map (default is 480).

See
http://grass.osgeo.org/grass64/manuals/html64_user/pngdriver.html

Hope this helps,
Markus


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

Message: 3
Date: Sat, 3 Mar 2012 16:15:08 +0000
From: Glynn Clements <[hidden email]>
Subject: Re: [GRASS-windows] grass_width, grass_heigt and
        grass_pngfile
To: "Liu, Huili" <[hidden email]>
Cc: "[hidden email]" <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=us-ascii


Liu, Huili wrote:

> I am trying to create a python script to get an image file as below:
>
> #get_img.py
> import os.path
> import sys # the sys module [2]
> from grass.script import core as grass # the core module [3]
> def main():
>     grass.run_command('d.his i=elevation_shade h=elevation')

This is wrong; it should be:

        grass.run_command('d.his', i='elevation_shade', h='elevation')

> if __name__ == "__main__": # this allows the script to be used as a module in other scripts or as a standalone script
>     #options, flags = grass.parser() #
>     sys.exit(main())
>
> But I got the default image file name,  map.png with GRASS_WIDTH=640 and GRASS_HEIGHT=480.
> Is there any way for me to setup  width and height and my image file name in grass.run_command?
> I searched the doc for a while but I still can not get a correct syntax.

        import os
        os.environ['GRASS_PNGFILE'] = filename
        os.environ['GRASS_WIDTH'] = str(width)
        os.environ['GRASS_HEIGHT'] = str(height)

--
Glynn Clements <[hidden email]>


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

_______________________________________________
grass-windows mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-windows


End of grass-windows Digest, Vol 64, Issue 2
********************************************