On 07/16/2013 04:28 PM, Elisa Dal Maso wrote:
Hi, I'm a PhD student in Italy and I am a new user of GRASS.
I have a problem in a weighted average with r.mapcalc.
There are 3 raster map (areas of species), with different extent but the same resolution, area has value 1, outside is null *.
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:

(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.


Instead of the "isnull()" functions, just set null to '0' with r.null for each raster before your mapcalc _expression_: i.e.
r.null Fraxinus_excelsior_raster null=0
same for each of the other Fraxious* ...
then, be sure you have set the region correctly:
g.region rast=`g.mlist type=rast pattern="Frax*" separator=,`
and finally
r.mapcalc "weighted =  (Fraxinus_excelsior_raster * 10.0 + ....+ ....)/23.0"

The resulting map have only 4 rectangles but it considers the sum of all the map (null values comprised).

How could I resolve the problem?
Thanks a lot!!!

Elisa



This mail was received via Mail-SeCure System.


_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

This mail was received via Mail-SeCure System.



_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to