[GRASS-user] mapcalc and cell coordinates

G. Allegri giohappy at gmail.com
Tue Jul 15 04:30:20 EDT 2008


> 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.

You're rigth Glynn, but how to check the row and col number in bash?I
could calculate it with the following straigthforward way

$x/(east-west) = $col/cols    -->  $col = $x*cols/(east-west)

and then use "floor($col)" as the col value.

Yet, could the precision problem arise in this case too?


More information about the grass-user mailing list