Thanks a million, Moritz. <div>Yours,</div><div>Ismael</div><div><br><div class="gmail_quote">2012/4/18 Moritz Lennert <span dir="ltr">&lt;<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 18/04/12 20:54, Ismael Gómez wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I would like to use the v.rast.stats inside a loop in a python script.<br>
The thing is I just need to get one of the nine columns it generates (sum).<br>
As it runs many times in the loop, it takes a lot of (unnecessary, for<br>
this script) time and also creates a huge table with too many<br>
(unnecessary, for this script) columns.<br>
I was wondering then if there was a way to specify the calculation for<br>
just that single statistic.<br>
</blockquote>
<br></div>
v.rast.stats is a script, so fairly easy to modify (see below for accessing it).<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Also, I wanted to ask you if there is a way to access the source code of<br>
a specific module (in this case, v.rast.stats) via web (without<br>
downloading the whole source code), just to have a quick look at it (and<br>
try to adapt it to my needs, eventually contribute to it if possible,<br>
</blockquote>
<br>
</div><a href="http://trac.osgeo.org/grass/browser/grass" target="_blank">http://trac.osgeo.org/grass/<u></u>browser/grass</a><br>
<br>
For the development version (aka grass7) go to trunk, for other version to branches.<br>
<br>
For v.rast.stats in the 6.4 release branch:<br>
<br>
<a href="http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/scripts/v.rast.stats/v.rast.stats" target="_blank">http://trac.osgeo.org/grass/<u></u>browser/grass/branches/<u></u>releasebranch_6_4/scripts/v.<u></u>rast.stats/v.rast.stats</a>.<br>

<br>
See &quot;Download in other formats&quot; at the bottom for downloading it.<br>
<br>
A quick and dirty guess would be that modifying<br>
<br>
line 247: BASECOLS=&quot;n min max range mean stddev variance cf_var sum&quot;<br>
<br>
and<br>
<br>
line 368    sed -e &#39;1d&#39; &quot;$STATSTMP&quot; | awk -F &quot;|&quot; &#39;{printf &quot;\nUPDATE &#39;${TABLE}&#39; SET &#39;${col1}&#39; = %i , &#39;${col2}&#39; = %.2f , &#39;${col3}&#39; = %.2f , &#39;${col4}&#39; = %.2f , &#39;${col5}&#39; = %.2f , &#39;${col6}&#39; = %.2f , &#39;${col7}&#39; = %.2f , &#39;${col8}&#39; = %.2f , &#39;${col9}&#39; = %.2f WHERE &#39;${KEYCOL}&#39; = %i;&quot;, $2,$3,$4,$5,$6,$7,$8,$9,$10,$<u></u>1}&#39; &gt; &quot;$SQLTMP&quot;<br>

<br>
could actually be enough.<span class="HOEnZb"><font color="#888888"><br>
<br>
Moritz<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Ismael G.</div><div>Ingeniero de Caminos (UPM). Ingénieur des Ponts et Chaussées (ENPC).</div><div>PhD researcher @ Urban &amp; Land Planning Department @ ETSICCP UPM <a href="http://www.caminos.upm.es/" style="color:rgb(17,85,204)" target="_blank">www.caminos.upm.es</a> +34 91 336 67 83</div>
<br>
</div>