Help using r.mapcalc

Malcolm Williamson malcolm at
Thu Jul 6 14:41:57 EDT 1995

On Thu, 6 Jul 1995, K.A.MOHD NASIR wrote:

> Dear Grass users,
> I need help in using r.mapcalc for my application. I would like to 
> use r.mapcalc in assigning different equations to different 
> categories within the same map coverage. For example, I would like 
> assign eqn A to category 1, eqn B to category 2, eqn C to category 3 
> and eqn D to category 4 within the same map coverage. How can I do 
> this using r.mapcalc or is there any other grass comands that I can 
> use for the purpose mentioned above.

Yes, r.mapcalc is your tool. You need to use "if-then-else" statements, 
like the following:

mapcalc> newmap = if(map==1, eqn_A, if(map==2, eqn_B, if(map==3, eqn_C)))

where eqn_A would be something like "map/(4+map)" or whatever.

Malcolm D. Williamson - GIS Specialist           E-mail: malcolm at
Center for Advanced Spatial Technologies      Telephone: (501) 575-6159
Ozark Rm. 12                                        Fax: (501) 575-5218 
University of Arkansas              
Fayetteville, AR 72701

More information about the grass-user mailing list