[GRASS-user] Tobler's hiking function

Glynn Clements glynn at gclements.plus.com
Fri Jan 26 05:43:31 EST 2007


mlage at usal.es wrote:

> >> Thank you very much, Glynn.
> >> The original Hiking Function is:
> >>
> >> W= 6 exp {-3.5*abs(Slope + 0.05)}
> >>
> >> Through this I want to estimate anisotropic cost movements in friction
> >> surfaces.
> >> Maybe the problem is that I haven't understood the r.mapcalc syntax...
> >
> > My problem is that I don't understand your syntax; what does "X exp Y"
> > mean?
> 
> It's   6 * exp {-3.5*abs(Slope+0.05)}
> So I guess it goes newmap="(6 * exp(-3.5*(abs(slopemap)+0.05)))/0.025"
> 0.025 it's for Distance (cell resolution). The Hiking Function estimates
> distance in Km and my DEM it's 25x25m.
> Do you think this syntax is correct, now?

It looks okay.

Although, for future reference, you should normally quote the entire
expression using single quotes, e.g.:

	r.mapcalc 'newmap = (6 * exp(-3.5*(abs(slopemap)+0.05)))/0.025'

Using single quotes ensures that nothing is changed by the shell. Use
double quotes if the expression contains shell variables or command
substitutions which need to be expanded before being passed to
r.mapcalc.

Also, you can use the ewres() and/or nsres() functions rather than
hard-coding the resolution, e.g.:

	r.mapcalc 'newmap = (6 * exp(-3.5*(abs(slopemap)+0.05)))/(ewres()/1000)'

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list