My goal:

Convert vertices to a poly line describing the general route to have 1 line describing the center line of a river.


  • The whole process has to be automated.
  • The raster can contain gaps.

The initial input is a raster containing a scan of a proposed river. This scan is of very low resolution (see yellow resulting pixels in picture). I have processed this as follows:

  • r.mfilter: High pass filter to sharpen the river using
  • r.reclass to reclass all non-river pixels to NULL
  • r.to.points to get the vertices of the raster cells


enter image description here

Now I want to connect these points to get a generalized (smoothed) line describing the points. I do not have a specific network to do a network analysis. Converting points to lines results in too many lines. Also, the nodes number does not correspond completely to the desired trajectory.

Any recommended approach or a different approach altogether to reach the desired result?


enter image description here

  • 1
    Did you try r.to.vect + grass.osgeo.org/grass76/manuals/v.to.lines.html (+ v.generalize)? – markusN May 23 '19 at 5:50
  • Hey, thank you for your reply. I have tried it today. I used r.to.vect to convert my raster to lines (you can select the output data type [area, line, point] and then tried to use several algorithms, however the problem, I think, is that the raster cells are disconnected and thus the output will be as well. – MarcM May 23 '19 at 12:59
  • 2
    To overcome the disconnected raster cells, you'll have to apply r.grow.distance then r.thin to get back to a single width raster. And finally r.to.vect – Micha May 23 '19 at 19:18
  • 1
    Eventually I ended up using r.grow as here I could specify the data type as CELL instead of DCELL as r.thin only works with integers. Thereafter, v.clean to remove any dangles. So your suggestion worked well! ! – MarcM May 24 '19 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.