[GRASS-user] mapcalc and cell coordinates

Glynn Clements glynn at gclements.plus.com
Mon Jul 14 07:15:42 EDT 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.

r.mapcalc "$outmap = if(abs(x() - $x) < $eps && abs(y() - $y) < $eps,$newval,$inmap)"

where everything preceded with a $ sign is a shell variable (or you
can just insert literal values into the expression).

Needless to say, this gets rather ugly (and inefficient) if you want
to change more than a few cells. In that situation, you would probably
be better off using r.in.xyz and r.patch.

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


More information about the grass-user mailing list