[GRASS-dev] grass7 - python script - moving window: how to simplify/accelerate r.mapcalc?
Helmut Kudrnovsky
hellik at web.de
Sat May 31 07:11:36 PDT 2014
>>>>grass.mapcalc("%s" % expr)
>
>or
>
>>>>grass.mapcalc( expr )
[...]
>GRASS_INFO_ERROR(8628,3): Kann
'C:\grassdata/nc_spm_08_grass7/user1/cell_misc/\/
>f_format' nicht finden.
>GRASS_INFO_END(8628,3)
>D2/3: G_file_name(): path = C:\grassdata/nc_spm_08_grass7/user1
>
>GRASS_INFO_ERROR(5412,1): An error occurred while running r.mapcalc
>GRASS_INFO_END(5412,1)
to answer my own question, new lines are not recognized correctly in the
expression,
so instead of
expr = "elevation_percentile_step2 = (100.0 / 48.0) * \\\n(%s)" % " +
\\\n".join(terms)
it should be
expr = "elevation_percentile3 = (100.0 / 48.0) * (%s)" % " + ".join(terms)
>>>expr
elevation_percentile3 = (100.0 / 48.0) * ((myelevnc[1,0] < myelevnc) +
(myelevnc[0,1] < myelevnc) + (myelevnc[1,1] < myelevnc) + (myelevnc[1,-1] <
myelevnc) + (myelevnc[-1,0] < myelevnc) + (myelevnc[0,-1] < myelevnc) +
(myelevnc[-1,-1] < myelevnc) + (myelevnc[-1,1] < myelevnc) + (myelevnc[2,0]
< myelevnc) + (myelevnc[0,2] < myelevnc) + (myelevnc[2,2] < myelevnc) +
(myelevnc[2,-2] < myelevnc) + (myelevnc[-2,0] < myelevnc) + (myelevnc[0,-2]
< myelevnc) + (myelevnc[-2,-2] < myelevnc) + (myelevnc[-2,2] < myelevnc) +
(myelevnc[3,0] < myelevnc) + (myelevnc[0,3] < myelevnc) + (myelevnc[3,3] <
myelevnc) + (myelevnc[3,-3] < myelevnc) + (myelevnc[-3,0] < myelevnc) +
(myelevnc[0,-3] < myelevnc) + (myelevnc[-3,-3] < myelevnc) + (myelevnc[-3,3]
< myelevnc) + (myelevnc[4,0] < myelevnc) + (myelevnc[0,4] < myelevnc) +
(myelevnc[4,4] < myelevnc) + (myelevnc[4,-4] < myelevnc) + (myelevnc[-4,0] <
myelevnc) + (myelevnc[0,-4] < myelevnc) + (myelevnc[-4,-4] < myelevnc) +
(myelevnc[-4,4] < myelevnc) + (myelevnc[5,0] < myelevnc) + (myelevnc[0,5] <
myelevnc) + (myelevnc[5,5] < myelevnc) + (myelevnc[5,-5] < myelevnc) +
(myelevnc[-5,0] < myelevnc) + (myelevnc[0,-5] < myelevnc) + (myelevnc[-5,-5]
< myelevnc) + (myelevnc[-5,5] < myelevnc) + (myelevnc[6,0] < myelevnc) +
(myelevnc[0,6] < myelevnc) + (myelevnc[6,6] < myelevnc) + (myelevnc[6,-6] <
myelevnc) + (myelevnc[-6,0] < myelevnc) + (myelevnc[0,-6] < myelevnc) +
(myelevnc[-6,-6] < myelevnc) + (myelevnc[-6,6] < myelevnc))
>>>grass.mapcalc( expr )
None
now the calculation works.
thanks
-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/grass7-python-script-moving-window-how-to-simplify-accelerate-r-mapcalc-tp5143161p5143417.html
Sent from the Grass - Dev mailing list archive at Nabble.com.
More information about the grass-dev
mailing list