[GRASS-user] Get values from raster map following a direction map for n steps

Stefan Blumentrath Stefan.Blumentrath at nina.no
Tue Nov 20 00:16:17 PST 2018


Dear all,

In an r.mapcalc expression, I would like to trace values along a direction map for 1 to n steps (e.g. looking 4 steps ahead along a path or stream or along a given direction (degrees or 45degrees).

I tried using the neighborhood modifier within an eval function in r.mapcalc. Unfortunately, using this command:
r.mapcalc --o << EOF
eval(elev_200 = elevation[1,1] - 200, elev_5 = 5 * elev_200[1,1], elev_p = pow(elev_5, 2))
gradient_1 = (0.5 * elev_200) + 0.8 * elev_p
EOF

I get the following error message:
syntax error, unexpected '[', expecting ')'

However, this command works fine:
r.mapcalc --o << EOF
eval(elev_200 = elevation[1,1] - 200, elev_5 = 5 * elevation[1,1], elev_p = pow(elev_5, 2))
gradient_1 = (0.5 * elev_200) + 0.8 * elev_p
EOF

My questions now are:
a) is it generally not supported to use the neighbourhood modifier on a temporary map defined in an eval() function in r.mapcalc?
b) are there other (efficient) approaches for those of us who do not know C (e.g. pygrass)?

I am grateful for any hint.

Kind regards,
Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181120/d16e6500/attachment.html>


More information about the grass-user mailing list