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

jean pierre huart jph at openjph.be
Tue Mar 8 07:15:01 PST 2016


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



More information about the grass-user mailing list