[GRASS-user] r.mapcalc: columns()/modulo - rounding issue, possible bugfeature ?

peter.loewe at gmx.de peter.loewe at gmx.de
Mon Feb 16 09:31:40 EST 2009


Hi,

I stumbled over this "funny" behavior of the col() function of r.mapcalc (GRASS6.2 and GRASS6.4, both on Linux). 

According to The Book, col() "returns current col of moving window".

I assume that for each row of a given raster layer col() should provide the values 1,2,3,4,5, etc. as it travels through the row. 

To produce a map of repeating value sequences (for example the numbers 1 2 3 4 ) the module operator can be used on the col()-function: 

col()  operator result
1      mod 4     = 1
2      mod 4     = 2
3      mod 4     = 3
4      mod 4     = 0
5      mod 4     = 1
6      mod 4     = 2
etc

this approach was put into mapcalc. The "1 + " makes sure that the sequence  runs from 1-4 not 0 - 3:

r.mapcalc modulo="(1 + ( col() % 4 ) )"

A map was produced in a Spearfish location (col() should operate independently from the projection).

Here it comes: 
For some (strange ?)reason, there are "ripples" in the "1 - 4" sequence.

Instead of going 1234 1234 1234 ad infinitum once in a while a number is omitted: 1234 1234 234  1234 134 etc.

Has anybody come across this behavior before ?
Is this a feature/good-thing ?
 
The phenomenon can be reproduced by using the above mentioned r.mapcalc command, displaying the result as a cell values layer.

1234, 1234, ...,
Peter
-- 
Dr. Peter Löwe
<peter.loewe at gmx.de>





Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL 
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a


More information about the grass-user mailing list