r.mapcalc (GRASS5.0beta)

Hi all,

I have some problems with r.mapcalc: I have imported several images with
r.in.bin. The data are 2 byte ints - everything went fine. I want to
calculate an average image by using r.mapcalc. It is not as simple as it
sounds first, since there are some gaps in the data (every day has an
image, but not all pixels in the images are "not zero", and the "non
zero" cells are not at constant places). So I thought to set up a
routine that

- adds all images together, resulting in an image "sum"
  (r.mapcalc sum=day1+day2+day3+...)

- creates an image of a sum of all "if(image)" resulting in "count"
  (r.mapcalc count=if(day1)+if(day2)+if(day3)+...)

- calculate the avarege by division "sum/count"
  (r.mapcalc average=sum/count)

Unfortunatly, it seems that every summation "implicitly" carries out
some masking, because the result is:

  sum=(day1+day2+day3+...)*(day1&&day2&&day3&&...)
  count=(if(day1)+if(day2)+if(day3)+...)*(day1&&day2&&day3&&...)

How can I "tell" GRASS5.0beta e.g. to take the NULL cells as 0???

Any suggestion will be highly appreciated :slight_smile:

  Stephan

--
------------------------------------------------------------------------

Stephan Eickschen Tel. : +49 (0)251 83-34704
Westfaelische Wilhelms-Universitaet Fax. : +49 (0)251 83-36100
Institute for Geophysics
Research Unit of Physical Glaciology email: eicksch@uni-muenster.de
Corrensstrasse 24
48149 Muenster
Germany
    http://earth.uni-muenster.de/~eicksch/
------------------------------------------------------------------------

Hello Stephan

On Feb 11, 6:06pm, Stephan Eickschen wrote:

I have some problems with r.mapcalc: I have imported several images with
r.in.bin. The data are 2 byte ints - everything went fine. I want to
calculate an average image by using r.mapcalc. It is not as simple as it
sounds first, since there are some gaps in the data (every day has an
image, but not all pixels in the images are "not zero", and the "non
zero" cells are not at constant places). So I thought to set up a
routine that

- adds all images together, resulting in an image "sum"
  (r.mapcalc sum=day1+day2+day3+...)

- creates an image of a sum of all "if(image)" resulting in "count"
  (r.mapcalc count=if(day1)+if(day2)+if(day3)+...)

- calculate the avarege by division "sum/count"
  (r.mapcalc average=sum/count)

Unfortunatly, it seems that every summation "implicitly" carries out
some masking, because the result is:

  sum=(day1+day2+day3+...)*(day1&&day2&&day3&&...)
  count=(if(day1)+if(day2)+if(day3)+...)*(day1&&day2&&day3&&...)

How can I "tell" GRASS5.0beta e.g. to take the NULL cells as 0???

Any suggestion will be highly appreciated :slight_smile:

Well, I'm not sure I can solve your problem, but we ran into problems using
NULLS with the old floating point code (before GRASS 5.0beta) and I wrote a
couple of programs to deal with them. One sets NULL values to zero (this one
you may be interested in, although I didn't quite finish it) and the other
attempts to fill in NULL values based on values of a 3x3 neighbourhood
surrounding the NULL value (i.e. they're averaged).

We haven't installed GRASS 5.0beta yet so I don't know if it works with that
version of GRASS, however, it shouldn't be too difficult to change it so that
it does (each program consists of a single file).

Anyway, let me know if you want the programs and I'll see what I can do.

--
Sincerely,

Jazzman (a.k.a. Justin Hickey) e-mail: jhickey@hpcc.nectec.or.th
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand

People who think they know everything are very irritating to those
of us who do. ---Anonymous

Jazz and Trek Rule!!!