[GRASS-user] mapcalc and cell coordinates

Glynn Clements glynn at gclements.plus.com
Tue Jul 15 00:24:38 EDT 2008


G. Allegri wrote:

> Thanks Glynn. Exaustive explanation :-)
> So I just need to check if the difference abs($x-x()) is lower then
> half the resolution...

In hindsight:

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 against x() and y() has the potential for a value which falls
exactly on (or very close to) the boundary between cells to match
either 2 (or 4) cells, or none, due to rounding error. Particularly if
the resolution isn't exactly representable in both binary and decimal.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list