[GRASS-user] compositing rasters

Tyler Smith tyler at plantarum.ca
Wed Jan 1 08:56:06 PST 2014


Dave Roberts <dvrbts at ecology.msu.montana.edu> wrote:
>Colleagues,
>
>    I know this must be easy, but I haven't found it.
>
>   Suppose I have three grids (a, b, and c) where each grid is 0 or 1, 
>and the 1s are mutually exclusive.  I want a new grid where if grid
>a=1 then newgrid = 1; if grid b=1 then new grid = 2; if grid c=1 then 
>newgrid = 3.
>
>     Something like  r.mapcalc "new=if(a,1) || if(b,2) || if(c,3)"
>
>seems like it ought to work but I can't seem to use multiple input file
>
>that way.
>
>Thanks in advance for any help, Dave
>-- 
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>David W. Roberts                                     office
>406-994-4548
>Professor and Head                                      FAX
>406-994-3190
>Department of Ecology                         email
>droberts at montana.edu
>Montana State University
>Bozeman, MT 59717-3460
>_______________________________________________
>grass-user mailing list
>grass-user at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/grass-user

What about

r.mapcalc new=a + b*2 + c*3

If the maps are mutually exclusive, only one of the three will be non-zero for each cell.

Tyler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20140101/359dd4bb/attachment.html>


More information about the grass-user mailing list