[GRASSLIST:1389] r.mapcalc

Hi,
I'm trying to embed r.mapcalc command in a bash script... I'm having
troubles understanding how r.mapcalc handles variables...

for example in a for loop:

r.mapcalc final_$sp_name = $sp_name && (dem <= $((max_$sp_name)) && (dem

= $((min_$sp_name))

I understand that some characters can cause troubles in the shell
interpretation for wich I should use something like...

r.mapcalc final_$sp_name \= $sp_name \&\& \(dem \<\= $((max_$sp_name))
\&\& \(dem \>\= $((min_$sp_name))\)

but it still doesn't work...

How does grass handles variables in r.mapcalc???

I'll appreciate any hint on this...

thanks

--
Horacio Samaniego
Dep. Ecologia
P. Universidad Catolica
Alameda 340
Santiago, Chile

Fono: (56 2)686 2950
Fax: (56 2)686 2621
Email: hsamanie@bio.puc.cl

(http://akodon.bio.puc.cl/horacio)

On Tue, Jan 23, 2001 at 12:32:30PM -0300, Horacio wrote:

Hi,
I'm trying to embed r.mapcalc command in a bash script... I'm having
troubles understanding how r.mapcalc handles variables...

for example in a for loop:

r.mapcalc final_$sp_name = $sp_name && (dem <= $((max_$sp_name)) && (dem
>= $((min_$sp_name))

I understand that some characters can cause troubles in the shell
interpretation for wich I should use something like...

r.mapcalc final_$sp_name \= $sp_name \&\& \(dem \<\= $((max_$sp_name))
\&\& \(dem \>\= $((min_$sp_name))\)

but it still doesn't work...

Horacio,

it's pretty easy:

r.mapcalc final_$sp_name="formula"
                          ^ ^

This will prevent the shell from expaning braces etc. wrongly.
However, you will need to use the "if()" function if you want to
test values.

See:
Bereich Geographie – Naturwissenschaftliche Fakultät – Leibniz Universität Hannover

and the two refs mentioned in "SEE ALSO" on this page.

Hope this helps

Markus

Markus Neteler wrote:

On Tue, Jan 23, 2001 at 12:32:30PM -0300, Horacio wrote:
> Hi,
> I'm trying to embed r.mapcalc command in a bash script... I'm having
> troubles understanding how r.mapcalc handles variables...
>
> for example in a for loop:
>
> r.mapcalc final_$sp_name = $sp_name && (dem <= $((max_$sp_name)) && (dem
> >= $((min_$sp_name))
>
>
> I understand that some characters can cause troubles in the shell
> interpretation for wich I should use something like...
>
>
> r.mapcalc final_$sp_name \= $sp_name \&\& \(dem \<\= $((max_$sp_name))
> \&\& \(dem \>\= $((min_$sp_name))\)
>
>
> but it still doesn't work...

Horacio,

it's pretty easy:

r.mapcalc final_$sp_name="formula"
                          ^ ^

This will prevent the shell from expaning braces etc. wrongly.
However, you will need to use the "if()" function if you want to
test values.

See:
http://www.geog.uni-hannover.de/grass/gdp/html_grass5/html/r.mapcalc.html

and the two refs mentioned in "SEE ALSO" on this page.

Hope this helps

Dear friends,

Of course that "quotes" do it... but i still have trouble (maybe b'cuz
i'm not a programer...) this is my script:

---------- start script ------------
max_acacia_caven=160
max_acaena_antarctica=1600
.
.
.

min_acacia_caven=10
min_acaena_antarctica=100
.
.
.

for sp_name in acacia_caven acaena_antarctica acaena_magellanica ...

do
  r.mapcalc final_$sp_name = $sp_name && (dem <= $((max_$sp_name)) &&
(dem >= $((min_$sp_name)))
  g.remove tmp_$sp_name
done
exit 0
----------- end ---------------------

The error I get is just a: "you have confused me"!
So I think that the thing is how I define the $((variable))... I'm
boubting that GRASS understand it, although the SHELL does!
if I do:

sp_name=acacia_caven;max_acacia_caven=160;min_acacia_caven=10

echo $((max_$sp_name))
I get -> 160
wich is what I need to "cut" my map....

Any idea?

Thank you very much.

Horacio

--
Horacio Samaniego
Dep. Ecologia
P. Universidad Catolica
Alameda 340
Santiago, Chile

Fono: (56 2)686 2950
Fax: (56 2)686 2621
Email: hsamanie@bio.puc.cl

(http://akodon.bio.puc.cl/horacio)

From - Thu Oct 25 08:08:01 2001
Received: from fw (virscan [139.17.1.10])
  by mehl.gfz-potsdam.de (8.9.3/8.9.3) with SMTP id CAA15878
  for <eicksch@gfz-potsdam.de>; Thu, 25 Oct 2001 02:34:24 +0200 (MET DST)
Received: from localhost (localhost [127.0.0.1])
  by ccis01.baylor.edu (8.9.1/8.9.1) with SMTP id TAA1302159;
  Wed, 24 Oct 2001 19:28:45 -0500 (CDT)
Received: from FS-EXCHANGE1.baylor.edu (mopsy.baylor.edu [129.62.3.250] (may be forged))
  by ccis01.baylor.edu (8.9.1/8.9.1) with ESMTP id TAA1300433
  for <GRASSLIST@listproc.baylor.edu>; Wed, 24 Oct 2001 19:28:41 -0500 (CDT)
Received: from mail.mcdonagh.com ([63.231.199.85]) by FS-EXCHANGE1.baylor.edu with Microsoft SMTPSVC(5.0.2195.2966);
   Wed, 24 Oct 2001 19:28:41 -0500
Received: from gorilla.flatplanet.cx [63.231.197.104] by mail.mcdonagh.com with ESMTP
  (SMTPD32-6.06) id AE547090208; Wed, 24 Oct 2001 19:35:32 -0500
Message-Id: <5.1.0.14.1.20010124192334.00a496b0@orangutang.private.flatplanet.cx>
X-Sender: morgan@orangutang.private.flatplanet.cx
X-Mailer: QUALCOMM Windows Eudora Version 5.1
Date: Wed, 24 Jan 2001 19:29:00 -0600
To: GRASSLIST@baylor.edu
From: Morgan Covill <morgan@flatplanet.cx>
Subject: [GRASSLIST:2602] startgrass.bat file ?
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
X-OriginalArrivalTime: 25 Oct 2001 00:28:41.0594 (UTC) FILETIME=[FF73E5A0:01C15CEB]
Sender: owner-GRASSLIST@baylor.edu
X-Listprocessor-Version: 8.2.10/991025/16:55 -- ListProc(tm) by CREN
X-Mozilla-Status: 8001
X-Mozilla-Status2: 00000000
X-UIDL: 3b29b16e0000151a
Status: O
Content-Length: 391
Lines: 8

Hi,
I have just installed GRASS for cygwin. I can get it to work in Xfree86 but
would like to try running it with star net xwin-32. The instructions for
starting grass with this x server refer to a startgrass.bat file. I cannot
find this file anywhere, has something changed that is not mentioned in the
readme document ? Do I need this file and if so, where can I get it.
Thanks
Morgan