[GRASS-user] Downscaling and aggregating raster categories/classes

Nikos Alexandris nik at nikosalexandris.net
Wed Feb 27 09:51:01 PST 2013


Hi list.

I am trying to perform the following:

A classified map  "A"  of 25m pix res. has two main categories B and C.  
Downscaling the map to 50m (map  "B") results in pixels which correspond to 4 
* 25m (original pixels).

Given the region extent is aligned, three possibilities may occur (near the 
borders between categories B=11 and C=22) in terms of abundance/coverage in 
the resampled map:

1. B = C  <-- Mixed (M)
____
|B|B|
|-----|
|C|C|
-------

2. B > C

|B|B|
|-----|
|C|B|
-------

3. B < C

|B|C|
|-----|
|C|C|
-------

The new "categorisation" scheme can be expressed as (in r.mapcalc -- pseudo-
code)

1) if( count(B) > count(C), B)

2) if( count(C) > count(B), C)

3) if( count(B) = count(C), M )

The r.resamp.stats module seems to fit most aggregation tasks.  In this 
particular case it could be the method=mode.  But,

1) the output is a DCELL map!  I can understand why it is deriving floating 
point values.  Is a simple r.mapcalc round() operation enough to get close to 
the desired values?  Would an "-i" switch (as in integer) make sense here?

2) What happens when "method=mode" and "count(B) == count(C)", as described 
above?

I know that something else can do it -- e.g. something like summing-up and 
recoding later.  That is however more steps.  Even, method=sum also outputs 
DCELL map(s).

Any recommendations? Can't this be done i a single step in grass (2 by 2 
window)?

I've been reading the old and very good tutorial on r.mapcalc  (thank you 
Markus for pointing to it).  Is it a better solution to construct this in 
r.mapcalc using the map[r,c] operator?

Two essential questions:

- how to get a 2 by 2   *moving*  window in r.mapcalc?
- how to replicate a "count()" method in r.mapcalc?

Thanks, Nikos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20130227/944d454e/attachment.pgp>


More information about the grass-user mailing list