[GRASS-user] distance along flow line to a particular feature

Hi Grass users,
I am quite new to Grass and I come here to get some hints and guidelines about
a particular problem I have.
I work on a watershed (on which I ran r.watershed, to get flow directions,
accumulation...) and inside this watershed I define a linear feature (raster
or vector) as the main stream.
I would like to calculate the distance (along the hydrographic network) of
each pixel of this watershed to the main stream. By distance I mean lenght
calculated along the flow lines defined by the flow directions. The desired
final output is a raster containing that distance to the main stream.
Has anybody done such a thing with Grass previously?
Thanks in advance,
Vincent.
--
Vincent Godard
Equipe de géodynamique
Laboratoire de Géologie
École Normale Supérieure
24, Rue Lhomond
75231 Paris Cedex 05, France
Tel: +33 1 44 32 22 63 Fax: +33 1 44 32 20 00
email: godard@geologie.ens.fr

Hi,
I've never done it, but i guess you have to consider to use a script using r.drain with the -n option....

draft of the script:
- extract x,y coordinates of each cell of your region (basin);
- foreach point run r.drain -n input=your_dem output=your_tmp_output coordinate=x,y
- set to null the river cells in your_tmp_output by using r.mapcalc;
- run r.univar map=your_tmp_output and extract the maximum (it is the number of cells to reach the river);
- write adding in a file the x,y,max values
- end of foreach
- import x,y,z to vector
- convert vector to raster

maybe too complicate???

It is just a first idea....

Cheers,
Maxi

//

Godard Vincent wrote:

Hi Grass users,
I am quite new to Grass and I come here to get some hints and guidelines about a particular problem I have. I work on a watershed (on which I ran r.watershed, to get flow directions, accumulation...) and inside this watershed I define a linear feature (raster or vector) as the main stream.
I would like to calculate the distance (along the hydrographic network) of each pixel of this watershed to the main stream. By distance I mean lenght calculated along the flow lines defined by the flow directions. The desired final output is a raster containing that distance to the main stream.
Has anybody done such a thing with Grass previously?
Thanks in advance,
Vincent.
  
--

Dr. Eng. Massimiliano Cannata
Scuola Universitaria Professionale della Svizzera Italiana
Istituto Scienze della Terra
Via Trevano, c.p. 72
CH-6952 Canobbio-Lugano
Tel: +41 (0)58 666 62 14
Fax +41 (0)58 666 62 09

Godard Vincent napisa?(a):

Hi Grass users,
I am quite new to Grass and I come here to get some hints and guidelines about
a particular problem I have.
I work on a watershed (on which I ran r.watershed, to get flow directions,
accumulation...) and inside this watershed I define a linear feature (raster
or vector) as the main stream.
I would like to calculate the distance (along the hydrographic network) of
each pixel of this watershed to the main stream. By distance I mean lenght
calculated along the flow lines defined by the flow directions. The desired
final output is a raster containing that distance to the main stream.
Has anybody done such a thing with Grass previously?

Markus Neteler has done something similar to what you describe.

http://grass.itc.it/grass60/screenshots/raster.php

(the "distance to water" one")

If that' what you mean, try asking him.

Maciek