[GRASS-dev] r.mapcalc - expression line to long

hi,

given in a pynthon script:

        offsets3 = [d
             for j in xrange(1,6+1)
             for i in [j,-j]
             for d in
[(i,0),(i,1),(i,2),(i,3),(i,4),(i,5),(i,6),(i,-1),(i,-2),(i,-3),(i,-4),(i,-5),(i,-6)]]
     
        terms3 = ["(DEM_smoothed_step3_coarsed[%d,%d] <
DEM_smoothed_step3_coarsed)" % d
             for d in offsets3]
     
        expr3 = "PCTL3 = (100.0 / 168.0) * (%s)" % " + ".join(terms3)

        grass.mapcalc( expr3 )

an attempt to build a r.mapcalc-expression with a 6x6 moving window.

the expression expands to:

PCTL3 = (100.0 / 168.0) * ((DEM_smoothed_step3_coarsed[1,0] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,1] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,2] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,3] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,4] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,5] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,6] <
DEM_smoothed_step3_coarsed) + (DEM_smoothed_step3_coarsed[1,-1] <
DEM_smoothed_step3_coarsed) +
[...]

by running the python script, a r.mapcalc-error pops up that the expression
line is to long.

any ideas to build a so long expression for r.mapcalc which can finish?

GRASS Version: 7.0.0svn
GRASS SVN Revision: 60869
Erstellungsdatum: 2014-06-20
Build Platform: i686-pc-mingw32
GDAL/OGR: 1.11.0
PROJ.4: 4.8.0
GEOS: 3.4.2
SQLite: 3.7.17
Python: 2.7.4
wxPython: 2.8.12.1
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Helmut Kudrnovsky wrote

hi,

given in a pynthon script:

        offsets3 = [d
             for j in xrange(1,6+1)
             for i in [j,-j]
             for d in
[(i,0),(i,1),(i,2),(i,3),(i,4),(i,5),(i,6),(i,-1),(i,-2),(i,-3),(i,-4),(i,-5),(i,-6)]]
     
        terms3 = ["(DEM_smoothed_step3_coarsed[%d,%d] <
DEM_smoothed_step3_coarsed)" % d
             for d in offsets3]
     
        expr3 = "PCTL3 = (100.0 / 168.0) * (%s)" % " + ".join(terms3)

        grass.mapcalc( expr3 )

mmmhhh, in the script there are two steps before two calculation with the
same moving window; there's isn't the error message, that the expression
line is too long.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281p5149303.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Helmut Kudrnovsky wrote:

by running the python script, a r.mapcalc-error pops up that the expression
line is to long.

Can you provide the exact message?

There shouldn't be any practial limitation on the length of an
expression in r60662 and later.

[Previously, there may have been OS-imposed limitations on the length
of a command line, but r60662 changed grass.script.mapcalc() to pass
the expression via stdin rather than the command line.]

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote

Helmut Kudrnovsky wrote:

by running the python script, a r.mapcalc-error pops up that the
expression
line is to long.

Can you provide the exact message?

There shouldn't be any practial limitation on the length of an
expression in r60662 and later.

[Previously, there may have been OS-imposed limitations on the length
of a command line, but r60662 changed grass.script.mapcalc() to pass
the expression via stdin rather than the command line.]

--
Glynn Clements

"Step 3: Calculation of elevation percentile PCTL3
...
...
Die Befehlszeile ist zu lang.
ERROR: An error occurred while running r.mapcalc"

translation:

"The command line is too long."

it's this script

http://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.valley.bottom/r.valley.bottom.py

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281p5149370.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Helmut Kudrnovsky wrote

Glynn Clements wrote

Helmut Kudrnovsky wrote:

There shouldn't be any practial limitation on the length of an
expression in r60662 and later.

[Previously, there may have been OS-imposed limitations on the length
of a command line, but r60662 changed grass.script.mapcalc() to pass
the expression via stdin rather than the command line.]

--
Glynn Clements

now tested with

GRASS version: 7.0.0svn
GRASS SVN Revision: 61115
Build Date: 2014-07-02
Build Platform: i686-pc-mingw32
GDAL/OGR: 1.11.0
PROJ.4: 4.8.0
GEOS: 3.4.2
SQLite: 3.7.17
Python: 2.7.4
wxPython: 2.8.12.1
Platform: Windows-Vista-6.0.6002-SP2 (OSGeo4W)

could it be that r60662 is only in trunk and not in 7.0.0svn?

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281p5149371.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

There shouldn't be any practial limitation on the length of an
expression in r60662 and later.

there are similar steps in the script

[1]
http://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.valley.bottom/r.valley.bottom.py#L205
[2]
http://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.valley.bottom/r.valley.bottom.py#L350

[1] works, [2] fails with the mentioned error.

thanks.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281p5149375.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Helmut Kudrnovsky wrote:

could it be that r60662 is only in trunk and not in 7.0.0svn?

Yes.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote

Helmut Kudrnovsky wrote:

could it be that r60662 is only in trunk and not in 7.0.0svn?

Yes.

--
Glynn Clements
_______________________________________________

any opinion about backporting r60662 [1] to releasebranch_7_0?

[1] http://lists.osgeo.org/pipermail/grass-commit/2014-June/031578.html

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281p5149807.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

Helmut Kudrnovsky wrote:

any opinion about backporting r60662 [1] to releasebranch_7_0?

I recommend backporting.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote

Helmut Kudrnovsky wrote:

any opinion about backporting r60662 [1] to releasebranch_7_0?

I recommend backporting.

--
Glynn Clements &lt;

glynn@.plus

&gt;
_______________________________________________
grass-dev mailing list

grass-dev@.osgeo

http://lists.osgeo.org/mailman/listinfo/grass-dev

tested locally. committed by r61207.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/r-mapcalc-expression-line-to-long-tp5149281p5150234.html
Sent from the Grass - Dev mailing list archive at Nabble.com.