[GRASS-dev] [GRASS GIS] #2770: r.mapcalc reports syntax error for valid script but no error for separate expressions

GRASS GIS trac at osgeo.org
Wed Nov 25 12:53:16 PST 2015


#2770: r.mapcalc reports syntax error for valid script but no error for separate
expressions
--------------------------+-------------------------
  Reporter:  marisn       |      Owner:  grass-dev@…
      Type:  defect       |     Status:  new
  Priority:  normal       |  Milestone:  7.0.3
 Component:  Raster       |    Version:  svn-trunk
Resolution:               |   Keywords:  r.mapcalc
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+-------------------------

Comment (by glynn):

 Replying to [comment:2 marisn]:

 > If I understood correctly, r.mapcalc works like this:
 {{{
 for output_row in computational_region:
     for output_cell in output_row:
         first expression
         second expression
         third expression
 }}}

 That's close enough for the purpose of this discussion.

 But in the interests of ~~pedantry~~ accuracy, I'll point out that the
 "for output_cell" loop actually occurs within the evaluation of each
 expression and subexpression. All of the C functions used to implement
 r.mapcalc's operators and functions take entire rows as arguments and
 return an entire row as their result.

 > thus "first" becomes a map only at the end of r.mapcalc run.
 Well, it's opened as an output map prior to reading any input; but output
 maps only become visible (or, if they already exist, the changes only
 become visible) when they are closed.

 An "identifier" is treated as an input map if and only if it hasn't
 previously occurred on the left-hand side of an "=" anywhere in the input
 expression(s). If it has so occurred, then it's treated as a variable,
 regardless of whether any map with that name already exists, and
 regardless of whether the assignment occurs at the top level (creating an
 output map) or nested within an expression (e.g. as an argument to
 eval()).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2770#comment:3>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list