[GRASS5] r.mapcalc result

Are there any special restrictions for the name of 'result' in r.mapcalc?

GRASS 5.7.-cvs:~/gdata/devel/raster > r.mapcalc pok-1=1
parse error, expecting `'=''
Parse error
GRASS 5.7.-cvs:~/gdata/devel/raster > r.mapcalc 'pok-1=1'
parse error, expecting `'=''
Parse error
GRASS 5.7.-cvs:~/gdata/devel/raster > r.mapcalc "pok-1=1"
parse error, expecting `'=''
Parse error

Radim

Radim Blazek wrote:

Are there any special restrictions for the name of 'result' in r.mapcalc?

GRASS 5.7.-cvs:~/gdata/devel/raster > r.mapcalc pok-1=1
parse error, expecting `'=''
Parse error
GRASS 5.7.-cvs:~/gdata/devel/raster > r.mapcalc 'pok-1=1'
parse error, expecting `'=''
Parse error
GRASS 5.7.-cvs:~/gdata/devel/raster > r.mapcalc "pok-1=1"
parse error, expecting `'=''
Parse error

Names which include r.mapcalc syntatic characters (e.g. minus) have to
be quoted, e.g.:

  r.mapcalc '"pok-1"=1'

  r.mapcalc "'pok-1'=1"

  r.mapcalc "\"pok-1\"=1"

  r.mapcalc
  Enter expressions, "end" when done.
  mapcalc> "pok-1"=1

Etc.

Note: the quotes must be present in the string which is passed to
r.mapcalc; when supplying the string on the command line, you have to
allow for the shell's processing.

The list of characters which can't be used in an unquoted name
consists of control characters, space, and the following:

  ^ # @ , " ' ( ) + - * / % > < ! = & | ? : ;

This is true for both map names and variable names, and is distinct
from GRASS' own restrictions (see G_legal_filename()), which apply
regardless of whether the name is quoted.

--
Glynn Clements <glynn.clements@virgin.net>

On Wednesday 26 May 2004 16:50, Glynn Clements wrote:

Names which include r.mapcalc syntatic characters (e.g. minus) have to
be quoted, e.g.:

  r.mapcalc '"pok-1"=1'

  r.mapcalc "'pok-1'=1"

  r.mapcalc "\"pok-1\"=1"

  r.mapcalc
  Enter expressions, "end" when done.
  mapcalc> "pok-1"=1

Etc.

Note: the quotes must be present in the string which is passed to
r.mapcalc; when supplying the string on the command line, you have to
allow for the shell's processing.

The list of characters which can't be used in an unquoted name
consists of control characters, space, and the following:

  ^ # @ , " ' ( ) + - * / % > < ! = & | ? : ;

This is true for both map names and variable names, and is distinct
from GRASS' own restrictions (see G_legal_filename()), which apply
regardless of whether the name is quoted.

In r.mapcalc manual:
"Quoting result is not allowed. However, it is never necessary to quote
result since it is always taken to be a raster map layer name."

is the rest of the manual correct or there are other changes?

Radim

Radim Blazek wrote:

> Names which include r.mapcalc syntatic characters (e.g. minus) have to
> be quoted, e.g.:
>
> r.mapcalc '"pok-1"=1'
>
> r.mapcalc "'pok-1'=1"
>
> r.mapcalc "\"pok-1\"=1"
>
> r.mapcalc
> Enter expressions, "end" when done.
> mapcalc> "pok-1"=1
>
> Etc.
>
> Note: the quotes must be present in the string which is passed to
> r.mapcalc; when supplying the string on the command line, you have to
> allow for the shell's processing.
>
> The list of characters which can't be used in an unquoted name
> consists of control characters, space, and the following:
>
> ^ # @ , " ' ( ) + - * / % > < ! = & | ? : ;
>
> This is true for both map names and variable names, and is distinct
> from GRASS' own restrictions (see G_legal_filename()), which apply
> regardless of whether the name is quoted.

In r.mapcalc manual:
"Quoting result is not allowed.

That has recently been changed.

However, it is never necessary to quote
result since it is always taken to be a raster map layer name."

That isn't true. And I don't think that it was ever true, even in the
old r.mapcalc (src/raster/r.mapcalc).

is the rest of the manual correct or there are other changes?

This isn't true:

       If the input comes directly from the keyboard and the
       result raster map layer exists, the user will be asked if
       it can be overwritten. Otherwise, the result raster map
       layer will automatically be overwritten if it exists.

Existing maps will be silently overwritten.

This isn't true:

       Continuation lines must end with a \ and have NO trailing
       white space (blanks or tabs). If the user does leave
       white space at the end of continuation lines, the error
       messages produced by r.mapcalc will be meaningless and the
       equation will not work as the user intended. This is
       important for the eval() function.

Trailing whitespace (any number of space, tab and carriage-return
characters) is allowed between the backslash and the newline.

This isn't entirely true:

       The function should require the user to type "end" or
       "exit" instead of simply a blank line. This would make
       separation of multiple scripts separable by white space.

It now understands "end" and "exit" as alternatives to a blank line.
Ignoring blank lines could be considered a significant
incompatibility.

The latter part of the REGION/MASK section is incorrect:

       Since a category value of 0 is used in GRASS for locations
       which do not exist in the raster map layer, the new raster
       map layer will contain the category value 10 in the loca­
       tions that did not exist in the original elevation.
       Therefore, in this example, it is essential that the
       boundaries of the geographic region be set to agree with
       the cell header.

       However, if there is a current mask, then the resultant
       raster map layer is masked when it is written; i.e., 0
       category values in the mask force zero values in the out­
       put.

Also, in the comment:

       It is advisable to put single quotes around the
       expression; e.g.:

            result = 'elevation * 2'

I would suggest quoting the entire statement, i.e.:

            r.mapcalc 'result = elevation * 2'

--
Glynn Clements <glynn.clements@virgin.net>

Hopefully somebody will fix the manpage.

Radim

On Thursday 27 May 2004 11:12, Glynn Clements wrote:

Radim Blazek wrote:
> > Names which include r.mapcalc syntatic characters (e.g. minus) have to
> > be quoted, e.g.:
> >
> > r.mapcalc '"pok-1"=1'
> >
> > r.mapcalc "'pok-1'=1"
> >
> > r.mapcalc "\"pok-1\"=1"
> >
> > r.mapcalc
> > Enter expressions, "end" when done.
> > mapcalc> "pok-1"=1
> >
> > Etc.
> >
> > Note: the quotes must be present in the string which is passed to
> > r.mapcalc; when supplying the string on the command line, you have to
> > allow for the shell's processing.
> >
> > The list of characters which can't be used in an unquoted name
> > consists of control characters, space, and the following:
> >
> > ^ # @ , " ' ( ) + - * / % > < ! = & | ? : ;
> >
> > This is true for both map names and variable names, and is distinct
> > from GRASS' own restrictions (see G_legal_filename()), which apply
> > regardless of whether the name is quoted.
>
> In r.mapcalc manual:
> "Quoting result is not allowed.

That has recently been changed.

> However, it is never necessary to quote
> result since it is always taken to be a raster map layer name."

That isn't true. And I don't think that it was ever true, even in the
old r.mapcalc (src/raster/r.mapcalc).

> is the rest of the manual correct or there are other changes?

This isn't true:

       If the input comes directly from the keyboard and the
       result raster map layer exists, the user will be asked if
       it can be overwritten. Otherwise, the result raster map
       layer will automatically be overwritten if it exists.

Existing maps will be silently overwritten.

This isn't true:

       Continuation lines must end with a \ and have NO trailing
       white space (blanks or tabs). If the user does leave
       white space at the end of continuation lines, the error
       messages produced by r.mapcalc will be meaningless and the
       equation will not work as the user intended. This is
       important for the eval() function.

Trailing whitespace (any number of space, tab and carriage-return
characters) is allowed between the backslash and the newline.

This isn't entirely true:

       The function should require the user to type "end" or
       "exit" instead of simply a blank line. This would make
       separation of multiple scripts separable by white space.

It now understands "end" and "exit" as alternatives to a blank line.
Ignoring blank lines could be considered a significant
incompatibility.

The latter part of the REGION/MASK section is incorrect:

       Since a category value of 0 is used in GRASS for locations
       which do not exist in the raster map layer, the new raster
       map layer will contain the category value 10 in the loca­
       tions that did not exist in the original elevation.
       Therefore, in this example, it is essential that the
       boundaries of the geographic region be set to agree with
       the cell header.

       However, if there is a current mask, then the resultant
       raster map layer is masked when it is written; i.e., 0
       category values in the mask force zero values in the out­
       put.

Also, in the comment:

       It is advisable to put single quotes around the
       expression; e.g.:

            result = 'elevation * 2'

I would suggest quoting the entire statement, i.e.:

            r.mapcalc 'result = elevation * 2'