[GRASS-user] Get values from raster map following a direction map for n steps
Moritz Lennert
mlennert at club.worldonline.be
Fri Nov 23 06:29:45 PST 2018
On 23/11/18 14:28, Markus Metz wrote:
>
>
> On Tue, Nov 20, 2018 at 9:16 AM Stefan Blumentrath
> <Stefan.Blumentrath at nina.no <mailto: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"
Cf the man page (Notes section):
"Any maps generated by a r.mapcalc command only exist after the entire
command has completed. All maps are generated concurrently, row-by-row
(i.e. there is an implicit "for row in rows {...}" around the entire
expression). Thus the #, @, and [ ] operators cannot be used on a map
generated within same r.mapcalc command run. "
Moritz
More information about the grass-user
mailing list