r.mapcalc help needed

Agustin Lobo lobo at Jasper.Stanford.EDU
Wed Mar 10 13:16:42 EST 1993

----- Begin Included Message -----

>From grass-lists-owner at max.cecer.army.mil Tue Mar  9 16:37:52 1993
Date: Tue, 9 Mar 93 17:20:03 MST
>From: ront at niwot.CFNR.ColoState.EDU (Ronald Thomas)
Sender: lists-owner at max.cecer.army.mil
Reply-To: grassu-list at max.cecer.army.mil
Sender: lists-owner at moon.cecer.army.mil.
Reply-To: grassu-list at moon.cecer.army.mil.
Precedence: Bulk
To: grassu-list at max.cecer.army.mil
Subject: r.mapcalc help needed
Content-Length: 1753


I'm in need of assistance in formulating a "r.mapcalc" statement.
I am attemping to produce a transformed vegetation index by using the
square root of ratioed TM bands. I'm using the formula:

TV1="(sqrt((('band.2'-'band.1')/('band.2'+'band.1')) + 0.5)) *

and I keep getting a single value as output.  Does the fact that the maps
(band.x) are integers have something to do with it?  Are the internal
computations within the string truncated to integers as in standard map
arithmetic, or do they remain floating because they are part of the square
root function?   Am I correct in assuming that the maps within the internal
parentheses are being added or subtracted first, these sums divided, then 
added to the  "0.5" , and the square root of this sum finally being
multiplied by 100,  as I would approach it manually, or does r.mapcalc 
approach this differently?  If so, can someone shed some light on how to
turn standard math notation into "mapcalc-speak"?  

Or, do I have to do this in ERDAS, which handles floating point values?
 If r.mapcalc will allow the use of floating points within an expression, why
 doesn't it handle the ratio of integers as floating point values until
 writing out a map?  Am I confusing anyone yet?

Thanks for any help offered!

^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
   Ronald Thomas                         ^  ront at meeker.cfnr.colostate.edu
    Natural Resources Spec. (GIS)        ^  
     Resources Management Division       ^   Phone: 303-586-3565  x285
      Rocky Mountain National Park       ^          700-323-7285  (FTS)
       Estes Park, CO  80517             ^ 
^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^

----- End Included Message -----

My guess is that you just have to make use of the float() function: any ratio 
between integers is an integer.
Also, why are you using TM1 and TM2 instead of TM4 and TM3?

More information about the grass-user mailing list