comparing r.cost and r.terracost [was: Re: [GRASS-user] affecting cat of closest feature as pixel value]

Moritz Lennert mlennert at club.worldonline.be
Tue Jul 14 11:53:06 EDT 2009


On 14/07/09 15:00, Hamish wrote:
> Moritz wrote:
>> So, differences are non-negligeable, but no idea how to
>> interpret them at this stage, i.e. don't know which one is
>> "correct".
> 
> I would suggect to try with some simple geometric cost, like
> was done for the Knight's move example graphic in the r.cost
> help page. Then you can use your eye to locate differing bias
> (e.g. from 8/16 compass points).

Ok, here's a try:

g.region n=10 s=0 w=0 e=10 res=1 -a
r.mapcalc one=1.0
echo "5|5" | v.in.ascii out=start
v.to.rast start use=val val=1 out=start
r.cost -k one start_rast=start out=r_cost
r.terracost one start_rast=start out=terra_cost
d.rast.num r_cost
d.rast.num terra_cost

This gives:

r.cost: http://geog-pc40.ulb.ac.be/grass/misc/r_cost.png
r.terracost: http://geog-pc40.ulb.ac.be/grass/misc/terra_cost.png

It seems as if r.terracost only counts have a distance between the 
original cell and its neighbors, but then goes on to count complete 
distances. This seems to be enough to explain the difference between the 
two results.

Don't know what is generally considered the "right" way, but intuitively 
I would side with r.cost.

Moritz


More information about the grass-user mailing list