<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" text="#333333">
<p>Hi Stefan,</p>
<p>Sorry If I'm not clear... Yes I want add my new map in the active
map display. Unfortunately "add created map(s) into layer tree”
tick-box does not appear in my GUI script (I don't know why) and
I would like to make it visible or to add another one in options
tab. Just do run_command("d.rast", map=my_map) does not work..</p>
<p>Cheers,</p>
<p>Frank<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 22/10/2018 à 10:20, Stefan
Blumentrath a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:DB7PR02MB45857C70056392464E87A52A9EF40@DB7PR02MB4585.eurprd02.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">Hi Frank,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">I think Laurents solution is for rendering maps
to file/image.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">Do I understand you correctly, that you are
looking for a solution for adding maps to the currently
active map display (and respective Layer manager)?<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">I have not found a documentation and would be
interested too. I assume one has to use wxgui code, like
e.g. here:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><a
href="https://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/core/render.py"
moz-do-not-send="true">https://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/core/render.py</a><o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">?<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">Yet, having the “Add created map(s) into layer
tree” tick-box that core modules have available also for
addons (without GUI programming for addon devs) would be
nice (if possible)…<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">Kind regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB">Stefan<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="color:windowtext"
lang="EN-US">From:</span></b><span
style="color:windowtext" lang="EN-US"> grass-user
<a class="moz-txt-link-rfc2396E" href="mailto:grass-user-bounces@lists.osgeo.org"><grass-user-bounces@lists.osgeo.org></a>
<b>On Behalf Of </b>Frank David<br>
<b>Sent:</b> søndag 21. oktober 2018 21:35<br>
<b>To:</b> Laurent C. <a class="moz-txt-link-rfc2396E" href="mailto:lrntct@gmail.com"><lrntct@gmail.com></a><br>
<b>Cc:</b> GRASS user list
<a class="moz-txt-link-rfc2396E" href="mailto:grass-user@lists.osgeo.org"><grass-user@lists.osgeo.org></a><br>
<b>Subject:</b> Re: [GRASS-user] d.rast in python script<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p><span lang="EN-GB">Hello Laurent,<o:p></o:p></span></p>
<p><span lang="EN-GB">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...<o:p></o:p></span></p>
<p><span lang="EN-GB">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 ?<o:p></o:p></span></p>
<p><span lang="EN-GB">and from where "img_file_name" is coming ?
(my layer's name is "my_map")<o:p></o:p></span></p>
<p><span lang="EN-GB">To remove raster from display, I just
manually remove from the layer tree.<o:p></o:p></span></p>
<p><span lang="EN-GB">Cheers,<o:p></o:p></span></p>
<p><span lang="EN-GB">Frank<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB">Le 20/10/2018 à 23:06,
Laurent C. a écrit :<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span lang="EN-GB">Hello Frank,<br>
<br>
It is not very straightforward, but it is possible.<br>
Here is an example on how I do it:<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB">import os<br>
import grass.script as gscript<br>
from grass.pygrass.gis.region import Region <o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"># Set general env<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB">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)<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Be aware that
every time you run your script, it will add layer on
the file.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">So you might want
to delete the png file between the runs.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Cheers,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Laurent<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB">Le ven. 19 oct. 2018
à 13:00, Frank David <</span><a
href="mailto:frank.david@geophom.fr"
moz-do-not-send="true"><span lang="EN-GB">frank.david@geophom.fr</span></a><span
lang="EN-GB">> 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>
> </span><a href="mailto:grass-user@lists.osgeo.org"
moz-do-not-send="true"><span lang="EN-GB">grass-user@lists.osgeo.org</span></a><span
lang="EN-GB"><br>
> </span><a
href="https://lists.osgeo.org/mailman/listinfo/grass-user"
moz-do-not-send="true"><span lang="EN-GB">https://lists.osgeo.org/mailman/listinfo/grass-user</span></a><span
lang="EN-GB"><o:p></o:p></span></p>
</div>
</blockquote>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB">-- <o:p></o:p></span></p>
<div style="margin-top:7.5pt;margin-bottom:7.5pt"
id="signature">
<p class="MsoNormal"><b><span
style="font-size:8.5pt;color:#A1CD1A" lang="EN-GB">Geophom</span></b><span
style="font-size:7.5pt;color:#666666" lang="EN-GB"><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>
</span><a href="http://www.geophom.fr"
moz-do-not-send="true"><span style="font-size:7.5pt"
lang="EN-GB">www.geophom.fr</span></a><span
style="font-size:7.5pt;color:#666666" lang="EN-GB"><o:p></o:p></span></p>
</div>
</div>
</div>
</blockquote>
</body>
</html>