This project is read-only.

Flow river direction

Oct 31, 2013 at 9:52 AM
is possible to calculate the flow direction of a river with dotspatial?
I need know the orientation of the flow direction of one pixel inside the river.
Oct 31, 2013 at 4:34 PM
What do you mean with "pixel inside the river"? Do you have a raster map with detailed river free surface? Or do you have the DEM of the watershed and want to understand where the river flows?

In any case I think you need to make a simple function yourself.
What you can do is to evaluate the drainage direction map starting from the elevation raster of the area in which your river flows (or of ther river free surface).
For understanding what it is you can search for taudem plugin for mapwindow.

In the website you find an explanation of some map elaboration for hydrological purposes. One of these is the D8 drainage direction and the Dinf drainage direction functions.

Anyway the drainage direction map tells you in each cell what is the direction of the flow (the direction of maximum slope between the 8 surrounding cells if you use a D8 algorithm, or an angle if you use the Dinf algorithm).
Therefore once you have such a map you can check the drainage direction corresponding to a cell in your river.

I made a tool written in Fortran which works with BDG and ESRI ASCII Rasters only, if you need it I can send it to you. However this tool would be very fast also if written in c# or, and easy to implement.

Nov 1, 2013 at 10:47 AM
I made the function D8, the problem that I have is that on the bottom of the river (I have only raster with altitude of rivers) not follow a desdenciente slope, for example, if i get a longitudinal section of the river the altitude are:

cell1 = 79.32; cell2 = 70; cell3 = 65 cell4 = 50 cell5 = 70 cell6 = 60 cell7= 45

and the result are: cell1 -go to- cell2 -go to- cell3 - go to- cell4 (stagnant!!)

I am trying make statistical mode of flow direction when i get a one cell stagnant for continue the river, but i don't know if is the best way.
Nov 1, 2013 at 3:20 PM
I don't know if I understood well.

You said you have only raster with rivers altitude. This means that you have a raster file with nodata outside rivers and data only along the river network?

In this case I think that a statistical solution would be fine (I cannot think of one right now but maybe you can take advantage of a flow accumulation information, see TAUDEM link I gave you to understand what it is).

On the other hand if you have problem with a raster that does not have values only along the river network you should implement a pit filling algorithm, which is an algorithm that fills depressions so the digital elevation model always have an outflow cell and no sink inside.
It is usually a computationally demanding algorithm so I would avoid to develop it in c# or I made one a long time ago based on an algorithm presented by Planchon and Darboux (A fast, simple and versatile algorithm to fill the depressions of digital elevation models) in 2001 in a journal named "CATENA" edited by elsevier at no. 46 pages 159-176.
I made it in Fortran and it is vary fast, but I would not expect it would be that fast in c#. I cannot release the code because it is owned by my company and it is willing to be used in a commercial application, but I think it is not so difficult to implement it if you are familiar with algorithms programming.