[GRASS-user] r.cost source ID question...
Dylan Beaudette
dylan.beaudette at gmail.com
Sat Mar 1 19:39:57 EST 2008
On Friday 29 February 2008, Jonathan Greenberg wrote:
> If I have a r.cost surface calculated from a set of vector points used
> as starting points, and some cost surface, is there any way to easily
> retrieve the SOURCE vector ID that leads to the lowest cost to get to
> any cell in the raster? E.g. from a given point, where is the point
> that costs the least to get to?
>
> --j
r.cost is generally used in conjunction with r.drain.
First a cost surface from:
- a starting point
- a set of starting points
- a line segment
is generated to:
- the edges of the region
- a stopping point
- a set of stopping points
Then r.drain is used to compute the least-cost-path between the starting
point/points/line and some arbitrary end point. With the idea that you
will "drain" some water down-slope the cost surface, back to your starting
point/points/line.
To find the least-cost-path between *any two points* I have generally found it
simplest to run r.cost + r.drain for every start/stop combination that I am
interested in. An example is posted here:
http://casoilresource.lawr.ucdavis.edu/drupal/node/244
note that the code describing this process on the referenced page is actually
an un-rolled foreach loop.
Hope that helps a little,
Dylan
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
More information about the grass-user
mailing list