<br>Marcello:<br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
&gt; &gt; But there is no way to avoid r.mapcalc, is there?<br>
<br></div></blockquote><div><br>Hamish:<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
</div>I doubt you&#39;d get very much faster or more efficient even by<br>
writing your own C module. (it would probably only take you a<br>
minute to create a r.zero module out of the doc/raster/r.example<br>
code; just change &quot;return x;&quot; to &quot;return 0;&quot; and compile.<br>
<br></blockquote><div><br>Well, out of curiosity, I made the changes to r.example and compiled it. I then made a small script that initializes a map with the dimensions of one of my maps ( 677 x 1114) inside a loop using the three approaches mentioned in this thread:<br>
<br>1 - r.mapcalc &quot;initialized_map=if(base_map&gt;999999,1,0)&quot;  # my very smart method :)<br>2 - r.mapcalc initialized_map=0 # Moritz method<br>3 - r.example input=initialized_map output=zero_map   # Hamish idea<br>
<br>Since I initialize rasters 374 times in my original script, I made the loop in this way.<br><br>Results:<br>1 - 49 seconds<br>2 - 19 seconds<br>3 - 58 seconds<br><br>Bottom line:  <br>- Thanks Moritz for the tip, it will save me at least 30 seconds from now on.<br>
- Thanks Hamish, because I never knew r.example existed and it was fun to test the different approaches. But, no, r.example should stay just as that.... an example :)<br><br>Thanks to all.<br><br>Cheers,<br>Marcello.<br></div>
<div><br><br>P.S.:<br><br>Hamish:<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
tip: to avoid all your scripts breaking when you want to use<br>
grass7, always add a space around the &#39;=&#39; in r.mapcalc.<br>
<br>
 r.mapcalc &quot;initialized_map = 0&quot;<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div> <br></div></div>I will keep it in mind from now on. Tks.<br>