<html style="direction: ltr;">
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body style="direction: ltr;"
    bidimailui-detected-decoding-type="latin-charset" text="#000000"
    bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 07/16/2013 04:28 PM, Elisa Dal Maso
      wrote:<br>
    </div>
    <blockquote
cite="mid:CABb8FvD+1=dLDkS95vBA6_n7gYJzE4Egwex8t0dY8BpQ3wWy+Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi, I'm a PhD student in Italy and I am a new user
        of GRASS.
        <div style="">I have a problem in a weighted average with
          r.mapcalc.</div>
        <div style="">There are 3 raster map (areas of species), with
          different extent but the same resolution, area has value 1,
          outside is null *.</div>
        <div style="">I would like to sum these areas with different
          weights (10, 9 and 4), then divide for the sum of weights
          (23), generating a float, and I have used this formula:</div>
        <div style=""><br>
        </div>
        <div style="">(10.*if(isnull(Fraxinus_excelsior_raster@Phalaen),
          0, 1)+9.*if(isnull(Fraxinus_angustifolia_raster@Phalaen), 0,
          1) +4.*if(isnull(Fraxinus_ornus_raster@Phalaen), 0, 1))/23.<br>
        </div>
        <div style=""><br>
        </div>
      </div>
    </blockquote>
    <br>
    Instead of the "isnull()" functions, just set null to '0' with
    r.null for each raster before your mapcalc expression: i.e.<br>
    r.null Fraxinus_excelsior_raster null=0 <br>
    same for each of the other Fraxious* ...<br>
    then, be sure you have set the region correctly:<br>
    g.region rast=`g.mlist type=rast pattern="Frax*" separator=,`<br>
    and finally<br>
    r.mapcalc "weighted =  (Fraxinus_excelsior_raster * 10.0 + ....+
    ....)/23.0"<br>
    <br>
    <blockquote
cite="mid:CABb8FvD+1=dLDkS95vBA6_n7gYJzE4Egwex8t0dY8BpQ3wWy+Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div style="">The resulting map have only 4 rectangles but it
          considers the sum of all the map (null values comprised).</div>
        <div style=""><br>
        </div>
        <div style="">How could I resolve the problem?</div>
        <div style="">
          Thanks a lot!!!</div>
        <div style=""><br>
        </div>
        <div style="">Elisa</div>
        <div style=""><br>
        </div>
        <div style=""><br>
        </div>
      </div>
      <br>
      This mail was received via Mail-SeCure System.<br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-user">http://lists.osgeo.org/mailman/listinfo/grass-user</a>

This mail was received via Mail-SeCure System.


</pre>
    </blockquote>
    <br>
  </body>
</html>