Aggregation problems

# We are trying to aggregate cells (say 3x3 or 10x10) and compute
# an average for that entire area.

Try using r.neighbors to average values over a number of cells (odd number
required), and then cut the resolution down by the corresponding amount.

e.g.
Let's say you want to average in a 5x5 region for a map called "elev"

g.region rast=elev
  Let's say this map is a 50m resolution
r.neighbors input=elev output=elev.avg method=average size=5
  You now have the averages you want, but the original rows and cols
g.region res=250
  250 = 5 * 50 (50 is the original res and 5 is the size input above)
r.mapcalc elev.avg=elev.avg
  elev.avg gets resampled every 5 rows and 5 cols (cutting memory by 25 times)

# We are trying to aggregate cells (say 3x3 or 10x10) and compute
# an average for that entire area.

Try using r.neighbors to average values over a number of cells (odd number
required), and then cut the resolution down by the corresponding amount.

e.g.
Let's say you want to average in a 5x5 region for a map called "elev"

g.region rast=elev
   Let's say this map is a 50m resolution
r.neighbors input=elev output=elev.avg method=average size=5
   You now have the averages you want, but the original rows and cols
g.region res=250
   250 = 5 * 50 (50 is the original res and 5 is the size input above)
r.mapcalc elev.avg=elev.avg
   elev.avg gets resampled every 5 rows and 5 cols (cutting memory by 25 times)

Which value is the r.mapcalc picking when it is doing the resampling ?
Is it doing it this way:

X****X****X****X****
********************
********************
********************
********************
X****X****X****X**** => XXXX
******************** XXXX
********************
********************
********************

or this way

********************
********************
**X****X****X****X**
********************
********************
******************** => XXXX
******************** XXXX
**X****X****X****X**
********************
********************

I think that r.mapcalc is doing it like in the first example and then the
result of the average operation will be that the average output map is shifted two
pixels towards west and two pixels towards north.
Please correct me if I'm wrong !!!

Lars

Lars Schylberg Email: larss@fmi.kth.se
Department of Photogrammetry
Royal Institute of Technology Tel. +46 8 790 86 33
S-100 44 STOCKHOLM, SWEDEN Fax. +46 8 790 66 10