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

Markus Metz markus.metz.giswork at gmail.com
Fri Nov 23 05:28:06 PST 2018


On Tue, Nov 20, 2018 at 9:16 AM Stefan Blumentrath <
Stefan.Blumentrath at nina.no> wrote:
>
> 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

elev_200 is an internal variable of the elev function with a single value,
and not a (temporary) map. Therefore elev_200[1,1] can't work.

You would need several calls to r.mapcalc, with the first one creating the
map elev_200, e.g.

r.mapcalc "elev_200 = elevation[1,1] - 200"
r.mapcalc "elev_p = pow(5 * elev_200[1,1], 2)"
r.mapcalc "gradient_1 = (0.5 * elev_200) + 0.8 * elev_p"

Markus M
>
>
>
> 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
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181123/a34446c6/attachment.html>


More information about the grass-user mailing list