[GRASS-dev] [GRASS GIS] #2877: r.mapcalc allow neigbourhood modifier to accept expression or NAME

#2877: r.mapcalc allow neigbourhood modifier to accept expression or NAME
-------------------------+-------------------------
Reporter: marisn | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.1.0
Component: Raster | Version: svn-trunk
Keywords: r.mapcalc | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
It seems that r.mapcalc map[row,col] accepts only integers as row and col.
It would be useful (in rare cases) to specify row or col as an expression
or name that results in integer.

Here are some examples that should work:
{{{
map[-1, ncols() - 1]
map[sampler_x_map, sampler_y_map]
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2877&gt;
GRASS GIS <https://grass.osgeo.org>

#2877: r.mapcalc allow neigbourhood modifier to accept expression or NAME
--------------------------+-------------------------
  Reporter: marisn | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.1.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: r.mapcalc
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by glynn):

Replying to [ticket:2877 marisn]:
> It seems that r.mapcalc map[row,col] accepts only integers as row and
col. It would be useful (in rare cases) to specify row or col as an
expression or name that results in integer.

Arbitrary offsets for the column are probably feasible, but still likely
to involve a fair amount of work.

Arbitrary offsets for the rows aren't feasible without a complete re-write
due to the row-by-row nature of r.mapcalc. Even with such a re-write, they
could require storing a significant portion of the map (possibly all of
it) in memory (if the row offset is different for each column, then you
need as many rows in memory as there are columns).

In that situation, you may as well use grass.script.array (or similar) to
make the map available as a numpy array and get the benefits of using a
real programming language.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2877#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>