[GRASS-dev] grass7 - python script - moving window: how to simplify/accelerate r.mapcalc?

Helmut Kudrnovsky hellik at web.de
Thu May 29 15:48:46 PDT 2014


hi,

in a python script within a mapcalc-expression I have moving window with 6
cells in all directions and a if(x,a,b) for each cell in

r.mapcalc "elevation_percentile_step2 = (100.0 / 48.0) * \
(if(eudem_osttirol[3,3] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[2,2] <
eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[1,1] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[-3,3]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-2,2] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-1,1] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[3,0] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[3,-3]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[2,0] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[2,-2]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[1,0] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[1,-1]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[0,3] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[0,2]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[0,1] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[0,-1]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[0,-2] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[0,-3] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-1,0] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-1,-1] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-2,0] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-2,-2] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-3,0] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-3,-3] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-4,4] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-5,5] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-6,6] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[0,4]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[0,5] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[0,6]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[4,4] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[5,5]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[6,6] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[4,0]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[5,0] < eudem_osttirol , 1, 0 ) + if(eudem_osttirol[6,0]
< eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[4,-4] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[5,-5] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[6,-6] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[0,-4] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[0,-5] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[0,-6] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-4,-4] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-5,-5] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-6,-6] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-4,0] < eudem_osttirol , 1, 0 ) \
+ if(eudem_osttirol[-5,0] < eudem_osttirol , 1, 0 ) +
if(eudem_osttirol[-6,0] < eudem_osttirol , 1, 0 ))"

any idea/hint to simplify and/or accelerate such a python script with such a
large moving window?

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-tp5143161.html
Sent from the Grass - Dev mailing list archive at Nabble.com.


More information about the grass-dev mailing list