[GRASSLIST:4582] Re: if and docell
Eric G. Miller
egm2 at jps.net
Tue Sep 24 22:09:41 EDT 2002
On Tue, Sep 24, 2002 at 06:04:59PM +0200, Alexander Fritz wrote:
> Is there a possibility to do if then calculations in GRASS and is there
> something similar to the DOCELL command in ARCINFO?
Nothing exactly like DOCELL, but you can use the
if(<cond>,<when true>,<when false>) and eval() with temp variables, to
do quite a few things. See the mapcalc algegra doc (PS) for examples.
uLtimately, every expression results in a single output.
For others: DOCELL, basically lets you write a mini procedure which may
have multiple inputs and outputs usually in conjunction w/ Arc Macro
Language constructs. Don't have a handy example but something like:
DOCELL {
a = b + c
e = if (a, a * atan(4.0), 1.0)
}
would translate to something like:
for (i = 0; i < nrows; i++)
for (j = 0; j < ncols; j++)
{
a[i][j] = b[i][j] + c[i][j];
e[i][j] = (a[i][j]) ? a[i][j] * atan(4.0) : 1.0;
}
So, it's how many times do you want to pass over the data...
--
begin 664 .signature
M<F5L;&E-("Y'(&-I<D4@/G1E;BYS<&I`,FUG93P)"`@("`@("`@("`@("`@(
M"`@("`@("`@("`@("`@("`A%<FEC($<N($UI;&QE<B`\96=M,D!J<',N;F5T
"/@H`
`
end
More information about the grass-user
mailing list