Re: [GRASS-user] mapcalc and cell coordinates

2008-07-15 Thread G. Allegri
If you want to test for the specific cell in which the given coordinates lie, you may be better off converting the coordinates to a row/col based upon the region settings, then testing against the results of row() and col() (but note: row() and col() are 1-based, not 0-based). Testing

Re: [GRASS-user] mapcalc and cell coordinates

2008-07-15 Thread Glynn Clements
G. Allegri wrote: If you want to test for the specific cell in which the given coordinates lie, you may be better off converting the coordinates to a row/col based upon the region settings, then testing against the results of row() and col() (but note: row() and col() are 1-based, not

Re: [GRASS-user] mapcalc and cell coordinates

2008-07-14 Thread G. Allegri
Yer, but as mapcalc has some built-in functions like x() and y() to retrieve the x-y coordinates, I think it could be easy to trasform them in projected coordinates. I'm writing a few lines in C to solve it, but I think I'll take a look to r.mapcalc code to see if it would be possible to add

Re: [GRASS-user] mapcalc and cell coordinates

2008-07-14 Thread Glynn Clements
G. Allegri wrote: How can I control mapalgebra if statements on the base of the coordinates values of a cell? The base problem is to change the values of some specific cells on the base of their coordinates. r.mapcalc $outmap = if(abs(x() - $x) $eps abs(y() - $y) $eps,$newval,$inmap)

Re: [GRASS-user] mapcalc and cell coordinates

2008-07-14 Thread Moritz Lennert
On 14/07/08 12:17, G. Allegri wrote: Yer, but as mapcalc has some built-in functions like x() and y() to retrieve the x-y coordinates, I think it could be easy to trasform them in projected coordinates. I'm writing a few lines in C to solve it, but I think I'll take a look to r.mapcalc code to

Re: [GRASS-user] mapcalc and cell coordinates

2008-07-14 Thread G. Allegri
Thanks Glynn. Exaustive explanation :-) So I just need to check if the difference abs($x-x()) is lower then half the resolution... 2008/7/14 Glynn Clements [EMAIL PROTECTED]: Moritz Lennert wrote: Well, this works: r.mapcalc brol3=if(y()=9521600 x()=427000,1,null()) but this doesn't:

Re: [GRASS-user] mapcalc and cell coordinates

2008-07-14 Thread Glynn Clements
Moritz Lennert wrote: Also note that the calculation involves multiplying by the resolution. You mean internally by mapcalc, or that I should include resolution into the calculation ? Internally. The point is that if you have e.g. a 100m x 100m square, and you set rows = cols = 300, so