[GRASS-user] How to define the png image dimensions when using d.mon?

Hello,

I've written a python script to generate an image combining a vector map (myvector) and a raster (myraster) that has been generated using a mask.
It works great by default and creates an image with the default dimensions 640x480 on a white background.

         gscript.run_command('d.mon', overwrite=True, start='png', output=filename)
         gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, self.mapset))
         gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, self.mapset), color='white', fill_color='none')
         gscript.run_command('d.mon', stop="png")

I would like to have a transparent background and to change the dimensions of the image to 1280x960.
Reading the documentation I had the impression that I just have to modify some variables, but it does not work.

         os.environ['GRASS_TRANSPARENT'] = 'TRUE'
         os.environ['GRASS_WIDTH'] = str(1280)
         os.environ['GRASS_HEIGHT'] = str(960)
         gscript.run_command('d.mon', overwrite=True, start='png', output=filename)
         gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, self.mapset))
         gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, self.mapset), color='white', fill_color='none')
         gscript.run_command('d.mon', stop="png")

Thanks in advance for any advice.
Ciao

--
Jean Pierre Huart

Sorry I've forgotten to precise that I'm using Grass v7.0.3 on ubuntu 14.04.

On 08/03/16 16:15, jean pierre huart wrote:

Hello,

I've written a python script to generate an image combining a vector map (myvector) and a raster (myraster) that has been generated using a mask.
It works great by default and creates an image with the default dimensions 640x480 on a white background.

        gscript.run_command('d.mon', overwrite=True, start='png', output=filename)
        gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, self.mapset))
        gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, self.mapset), color='white', fill_color='none')
        gscript.run_command('d.mon', stop="png")

I would like to have a transparent background and to change the dimensions of the image to 1280x960.
Reading the documentation I had the impression that I just have to modify some variables, but it does not work.

        os.environ['GRASS_TRANSPARENT'] = 'TRUE'
        os.environ['GRASS_WIDTH'] = str(1280)
        os.environ['GRASS_HEIGHT'] = str(960)
        gscript.run_command('d.mon', overwrite=True, start='png', output=filename)
        gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, self.mapset))
        gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, self.mapset), color='white', fill_color='none')
        gscript.run_command('d.mon', stop="png")

Thanks in advance for any advice.
Ciao

--
Jean Pierre Huart

OpenJph
19, rue de la fontaine
1340 Ottignies
web: www.openjph.be
email: jph@openjph.be
tel: +32 487 95 77 75
skype: jeanpierre.huart

d.mon is designed for interactive use. If you're writing a script,
don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
environment variables.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

2016-03-11 13:36 GMT+01:00 Glynn Clements <glynn@gclements.plus.com>:

d.mon is designed for interactive use. If you're writing a script,
don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
environment variables.

not really, beside wx monitors, you can use cairo or png (useful for
scripting). Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

Martin Landa wrote:

> d.mon is designed for interactive use. If you're writing a script,
> don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
> environment variables.

not really, beside wx monitors, you can use cairo or png (useful for
scripting). Martin

You appear to be misunderstanding what "interactive" means in this
context. It doesn't necessarily imply a GUI.

The only situation where a script should be using d.mon is if it
really is a "script", in the sense of a canned sequence of commands
which is meant to be "replayed" as part of an interactive workflow.

Anything which tries to behave like a typical program should manage
the relevant environment variables directly.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

2016-03-26 18:52 GMT+01:00 Glynn Clements <glynn@gclements.plus.com>:

Martin Landa wrote:

> d.mon is designed for interactive use. If you're writing a script,
> don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
> environment variables.

not really, beside wx monitors, you can use cairo or png (useful for
scripting). Martin

You appear to be misunderstanding what "interactive" means in this
context. It doesn't necessarily imply a GUI.

I was just responding to your sentence "If you're writing a script,
don't use it."

The only situation where a script should be using d.mon is if it
really is a "script", in the sense of a canned sequence of commands
which is meant to be "replayed" as part of an interactive workflow.

Right. Ma