<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello Laurent,</p>
<p>Thank you for your help. I'm very surprised by the complexity of
the way to display a raster. I thought that only d.rast was
needed. Other grass command are so simple to use...<br>
</p>
<p>Anayway, I don't understand why you need to set a image width and
height. is it pixel number between west to east and south to north
from region ?</p>
<p>and from where "img_file_name" is coming ? (my layer's name is
"my_map")</p>
<p>To remove raster from display, I just manually remove from the
layer tree.</p>
<p>Cheers,</p>
<p>Frank<br>
</p>
<br>
<div class="moz-cite-prefix">Le 20/10/2018 à 23:06, Laurent C. a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CABmXgEGg1UGWUB9n+haUxJANJWzzGUYOaHcxe1a4jjuuVxNRrw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">Hello Frank,<br>
<br>
It is not very straightforward, but it is possible.<br>
Here is an example on how I do it:<br>
<div><br>
</div>
import os<br>
import grass.script as gscript<br>
from grass.pygrass.gis.region import Region
<div><br>
</div>
<div># Set general env<br>
</div>
os.environ['GRASS_RENDER_IMMEDIATE'] = "cairo"<br>
os.environ['GRASS_RENDER_FILE_COMPRESSION'] = "9"<br>
os.environ['GRASS_RENDER_FILE_READ'] = "TRUE"<br>
<br>
# Set image size using the region<br>
region = Region()<br>
xr = region.cols<br>
yr = region.rows<br>
ratio = xr/yr<br>
height = int(WIDTH / ratio) # Choose the width you like<br>
os.environ['GRASS_RENDER_WIDTH'] = str(WIDTH)<br>
os.environ['GRASS_RENDER_HEIGHT'] = str(height)<br>
<br>
# Then you can draw<br>
os.environ['GRASS_RENDER_FILE'] = img_file_name<br>
gscript.run_command('d.rast', map=my_map, quiet=True)<br>
<div><br>
</div>
<div><br>
</div>
<div>Be aware that every time you run your script, it will add
layer on the file.</div>
<div>So you might want to delete the png file between the runs.<br>
</div>
<div><br>
</div>
<div>Cheers,<br>
</div>
<div>Laurent<br>
</div>
<div><br>
</div>
Le ven. 19 oct. 2018 à 13:00, Frank David <<a
href="mailto:frank.david@geophom.fr" moz-do-not-send="true">frank.david@geophom.fr</a>>
a écrit :<br>
><br>
> Hello,<br>
><br>
> I wrote some python script and I do not find how to display
created<br>
> rasters.<br>
><br>
> I tried to use d.rast but I believe this command is not
designed to be<br>
> used in python script (no monitor available with d.mon -l).
Am I wright<br>
> ? so how to do ?...<br>
><br>
> Thank you for your help.<br>
><br>
> Frank<br>
><br>
> _______________________________________________<br>
> grass-user mailing list<br>
> <a href="mailto:grass-user@lists.osgeo.org"
moz-do-not-send="true">grass-user@lists.osgeo.org</a><br>
> <a
href="https://lists.osgeo.org/mailman/listinfo/grass-user"
moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/grass-user</a></div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<style>
div#signature {font-size:10px;color:#666;margin:10px 0}
span#geophom {font-size:11px;color:#A1CD1A}
div#important {font-size:10px;color:#CB110B;font-style:italic}
</style>
<div id="signature"> <span id="geophom"><b>Geophom</b></span><br>
327 rue de Vieille Cour 44521 OUDON<br>
Tel +33(0)2 85 52 02 59 - Port +33(0)6 04 47 91 06<br>
<a class="moz-txt-link-abbreviated" href="http://www.geophom.fr">www.geophom.fr</a><br>
</div>
</div>
</body>
</html>