[GRASS-user] How to define the png image dimensions when using d.mon?
jean pierre huart
jph at openjph.be
Wed Mar 9 06:39:21 PST 2016
Thanks Vinay, for the suggestion but I get an error on the d.out.file
instruction.
By the way, I've investigated the problem a bit further and found that I
mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in
obtaining a solution but not 100% satisfactory.
First trial create a unique image combining raster and vector, but width
and height remains at default and background is not transparent:
os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
os.environ['GRASS_RENDER_WIDTH'] = str(1280)
os.environ['GRASS_RENDER_HEIGHT'] = str(960)
os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
self.gscript.run_command('d.mon', overwrite=True, start='png',
output=filename)
self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset)
self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
self.gscript.run_command('d.mon', stop="png")
Second trial successfull for obtaining desired width, height and
transparency of the background but creating 2 images one for the raster
and the other for the vector, now I would like to combine them to have
only one image:
os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
os.environ['GRASS_RENDER_WIDTH'] = str(1280)
os.environ['GRASS_RENDER_HEIGHT'] = str(960)
os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
Modifying this with the following
os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
ends with only the image of the vector.
I've the feeling that using d.mon would be preferable, but it seems that
it does not take into account the environment variables (at the
exception of GRASS_RENDER_FILE) that I propose.
If you have other suggestions to go further I'll be very gratefull.
Ciao
--
Jean Pierre Huart
On 09/03/16 05:10, Vinay Elothunkal wrote:
> Hi jean pierre huart,
>
> I have exported png image using module "d.out.file",(I have pasted a
> part of the script below which I have used. I hope this will help you....
> .......................................................
> import grass.script as g
> import os
> import shutil
> import time
> g.run_command('r.colors',map=str(i),rules='color_table.txt')
> g.start_command('d.mon', start='wx1')
> time.sleep(10)
> g.run_command('d.rast', map=str(i))
> time.sleep(10)
> g.run_command('d.vect', map=str(i))
> time.sleep(40)
> g.run_command('d.out.file',output=str(i),format='png',size=(2403,2403))
> time.sleep(10)
> g.run_command('d.mon', stop='wx1')
> time.sleep(10)
> .................................................................
>
> Regards,
> Vinay
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160309/699a6856/attachment.html>
More information about the grass-user
mailing list