[GRASS-user] mapcalc and cell coordinates
Moritz Lennert
mlennert at club.worldonline.be
Mon Jul 14 07:21:07 EDT 2008
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 see if it would be possible to add something like
> x_coord() and y_coord()...
>
> 2008/7/14 Paul Kelly <paul-grass at stjohnspoint.co.uk>:
>> On Mon, 14 Jul 2008, 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.
>> I suspect this might not be possible with r.mapcalc, because each variable
>> in an r.mapcalc expression is effectively an entire map and the expression
>> used to generate the output map can't be changed based on the co-ordinates
>> of individual cells in the input map. I.e., the same expression applies to
>> each and every cell in the output map.
>>
>> That's my understanding anyway, based on an answer Glynn gave me a few years
>> ago:
>> http://lists.osgeo.org/pipermail/grass-user/2003-January/008182.html
>> Does that seem relevant to your case?
Well, this works:
r.mapcalc brol3=if(y()<=9521600 && x()<=427000,1,null())
but this doesn't:
r.mapcalc brol3=if(y()==9521600 && x()==427000,1,null())
which raises the issue of precision of the coordinates...
Moritz
More information about the grass-user
mailing list