Dear all,

would anyone be so kind to provide a simple example with a `t.rast.algebra` expression that involves

- the if() conditional call and the inverse selection operator, ie.: {!:,equal}
- if() and {!:,equal,r}


I cannot find a way to build a valid expression that includes both of these.

The following works:
```
t.rast.algebra expression='test = if({equal}, A1 >= -30, A2)' base=test nprocs=40
```

However, adding the inverse selection operator, won't do:
```
t.rast.algebra expression='test = if({!:,equal}, A1 >= -30, A2)' base=test3 nprocs=40 --o
Traceback (most recent call last):
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 132, in <module>
    sys.exit(main())
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 124, in main
    pc = p.parse(expression, basename, grass.script.overwrite())
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_raster_algebra.py", line 110, in parse
    self.parser.parse(expression)
File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_algebra.py", line 3042, in p_error raise SyntaxError("syntax error on line %d, position %i token %s near '%s' expression '%s'" % SyntaxError: syntax error on line 1, position 11 token T_SELECT_OPERATOR near '{!:,equal}' expression 'test = if({!:,equal}, A1 >= -30, A2)'
```

Even the theoretically equivalent expression (to the first one) won't do:
```
→ t.rast.algebra expression='test = if({:,equal}, A1 >= -30, A2)' --o base=test3 nprocs=40
Traceback (most recent call last):
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 132, in <module>
    sys.exit(main())
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/scripts/t.rast.algebra", line 124, in main
    pc = p.parse(expression, basename, grass.script.overwrite())
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_raster_algebra.py", line 110, in parse
    self.parser.parse(expression)
File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/nik/code/miniconda3/envs/py385/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
File "/osgeo/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/temporal_algebra.py", line 3042, in p_error raise SyntaxError("syntax error on line %d, position %i token %s near '%s' expression '%s'" % SyntaxError: syntax error on line 1, position 11 token T_SELECT_OPERATOR near '{:,equal}' expression 'test3 = if({:,equal}, A1 >= -30, A2)'
```
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to