[GRASS-user] least cost path analysis question

Markus Metz markus.metz.giswork at googlemail.com
Thu Nov 19 10:27:10 EST 2009


Hi,

I think you have to determine each path separately and at the end patch 
them all together to get the path pts1 -> pts2 -> pts3 -> pts4 -> pts1.
The least costly path from e.g. pts1 to pts3 may not go through pts2, 
that's why the complete path needs to be forced through pts2, pts3, and 
pts4 and actually consists of several paths (e.g. one circular mountain 
hiking trail visiting 3 peaks, the least costly path from start point to 
end point is staying where you are...).

Something like
r.walk -k elevation=dem friction=cost output=output_1_2 
outdir=outdir_1_2 coordinate=pts1 stop_coordinate= pts2
r.walk -k elevation=dem friction=cost output=output_2_3 
outdir=outdir_2_3 coordinate=pts2 stop_coordinate= pts3
r.walk -k elevation=dem friction=cost output=output_3_4 
outdir=outdir_3_4 coordinate=pts3 stop_coordinate= pts4
r.walk -k elevation=dem friction=cost output=output_4_1 
outdir=outdir_4_1 coordinate=pts4 stop_coordinate= pts1

# Knight's move, so vector output seems adequate
r.drain -d input=output_1_2 indir=outdir_1_2 coordinate=pts2 
voutput=voutdir_1_2
...

v.patch input=voutdir_1_2,voutdir_2_3,voutdir_3_4,voutdir_4_1 output=mypath

Just a guess,

Markus M


Maxime Phaneuf wrote:
> Hi guys.
>
> I want to use r.walk or r.cost, followed by r.drain to create least cost
> paths. I've got no problem doing that with only 1 starting point and 1
> stopping point.
>
> My problem is when I try to use multiple starting and stopping points. I saw
> that the coordinate and stop_coordinate were MULTIPLE=yes. But I don't
> really know I to declare each point.
>
> Let's say I've got those 4 points: pts1, pts2. pts3, pts4. I want to create
> a path going from pts1 to pts2, pts2 to pts3, pts3 to pts4, and pts4 to
> pts1. 
>
> I've tried this: 
> r.walk -k elevation=dem friction=cost output=output
> coordinate=pts1,pts2,pts3,pts4 stop_coordinate= pts2,pts3,pts4,pts1 
> and a lot of other rearrangement of the coordinate and stop_coordinate
> parameters, without much success. 
> I'm trying some configuration where pts4 does go back to pts1 and some where
> pts4 doesn't go back to pts1.
>
> Does someone know how to configure r.walk, r.cost and r.drain to include
> multiple coordinates?
>   
> Thanks,
> Maxime Phaneuf
>   


More information about the grass-user mailing list