[GRASSLIST:4531] Re: r.mapcalc and environment variables - New trouble

Daniel Victoria daniel_victoria at yahoo.com
Wed Sep 18 16:08:42 EDT 2002


Thanks for all the help, now I can output from a bash
script to r.mapcalc. But now I bumped into a new
problem.
In my formula line I have two integer constants that
are calculated during the bash script but in the
formula I need the result of the division on a
floating point form. Since I don't think there is a
way to do floating point calculations in bash I just
put on my formula line something like ($m1/$m2) and
I'd get (13/18).

The problem now is this. When I run r.mapcalc like
this
r.mapcalc output=blabla(13/18)blabla
I get  different result from
r.mapcalc output=blabla(0.722223)blabla

Is this an illigal thing in r.mapcalc (13/18)??
How should I go about this???

Thanks

Daniel

--- Pierre GERARD-MARCHANT <pg56 at cornell.edu> wrote:
> > You should try .
> >
> > r.mapcalc output="$i+bla bla bla."
> >
> >
> > The difference lie in the quotes (at least it work
> or me).
> 
> That's a basic aspect of bash: you need your $i to
> be substituted by its 
> actual value, hence, the quote substitution
> 
> Either you use the 
> for i in `cat images`; do
>       r.mapcalc "output=$i+bla bla bla..."
> done
> 
> or you can use
> 
> for i in whatever; do
>     echo "output=$i+blahblah" | r.mapcalc
> done
> 
> 
> 
> 
> -- 
> ---------------------------------------------
> Soil & Water Lab.
> Biological and Environmental Engineering Dept.
> Cornell University
> 222 Riley-Robb Hall
> ITHACA, NY 14853 - USA
> Tel : 607-255-2463/1819
> "It's more fun to compute" - Kraftwerk
> ---------------------------------------------
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com



More information about the grass-user mailing list