[GRASS-dev] grass7 - python script - moving window: how to simplify/accelerate r.mapcalc?
Glynn Clements
glynn at gclements.plus.com
Sat May 31 17:50:35 PDT 2014
Helmut Kudrnovsky wrote:
> but then while do
>
> >>>grass.mapcalc("%s" % expr)
>
> or
>
> >>>grass.mapcalc( expr )
>
> an error raise up with following message with DEBUG=3
>
> GRASS 7.1.svn> D2/3: G_file_name(): path =
> C:\grassdata/nc_spm_08_grass7/user1
> D1/3: G_find_raster2(): name=\ mapset=
Ugh.
Can you try replacing the grass.mapcalc() call with:
grass.write_command('r.mapcalc', file = '-', stdin = expr)
Or maybe it requires CR+LF on Windows:
expr = "elevation_percentile = (100.0 / 48.0) * \\\r\n(%s)" % " + \\\r\n".join(terms)
grass.mapcalc(expr)
Alternatively, just omit the line breaks from the expression:
expr = "elevation_percentile = (100.0 / 48.0) * (%s)" % " + ".join(terms)
grass.mapcalc(expr)
I'm not sure whether Windows even allows newlines in command-line
arguments. If it does, then it would suggest a bug in Python's
subprocess module, which handles the conversion of the argument list
to a string.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list