[GRASS-user] 6.4 vs 7.0

Glynn Clements glynn at gclements.plus.com
Sat Jan 16 18:05:48 EST 2010

Paolo Craveri wrote:

> I have some scripts which perfectly work in GRASS 6.4 whereas in GRASS
> 7.0 they give  problems.
> Here some examples:
> r.mapcalc 'grid1=rand(1,10)' #works in GRASS 6.4;
> ## in 7.0 I need:
> r.mapcalc expr='grid1=rand(1,10)' –overwrite
> echo "UPDATE polyNoTopology \
> SET label='poly$a' WHERE cat=$index" | db.execute ##works in GRASS
> 6.4; in 7.0 I need:
> echo "UPDATE polyNoTopology \
> SET label='poly$a' WHERE cat=$index" | db.execute in=-
> echo "5,3" | v.in.ascii out=point fs="," cat=0 --o # works perfectly
> in 6.4 but not in 7.0
> ## in 7.0 I have to create a file (perhaps, is there a better way?)
> echo "5,3">coord
> v.in.ascii input=coord out=point fs="," cat=0 --o
> Is there a rule of thumb for  this... new syntax ? (e.g. “no pipe at all”?)
> Do I have to test version (g.version) in all my (bash) scripts ?
> Is there a workaround, perhaps any tips and tricks,  to avoid modify
> all my scripts in order to work in 6.4 **and** in 7.0 ?
> (ok: perhaps python scripting should be a solution; I'm trying...)

The 7.0 version of r.mapcalc uses G_parser(); an expression can be
given on the command line using expression= (or any unique
abbreviation). However, as this is the first parameter, it can be
omitted, *provided* that the expression doesn't have the form
"variable=value". Inserting a space before the "=" is sufficient, so

	r.mapcalc 'grid1 = rand(1,10)'

will work in both 7.0 and older versions.

For modules which require e.g. in=- in 7.0 and don't accept it in 6.x,
you could try using in=/dev/stdin, although this may not work on all

Alternatively, you could file bug reports against the 6.4 modules for
not accepting "-" as an input filename. There really isn't any excuse
for not implementing this feature.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list