QGIS – Converting Raster to Vector by Generating Center Lines

qgisvectorization

I have a binary raster containing boundary pixels with the value 1 (white) and no-boundary pixels with the value 0 (black):

enter image description here

I would like to vectorize the raster by keeping one center line trough the boundary pixels. However, most polygonize methods I tried (e.g., gdalogr:polygonize, result in two lines around the outline of the boundary pixels (red lines) or no output (saga:gridskeletonization):
enter image description here

Did I miss any method with which this can be easily done? Or do I have to vectorize the raster first to a vector layer containing two parallel lines and find a way from there to skeletonize/centerline the two lines?

Best Answer

GRASS GIS is able do this.

You need two steps:

  1. r.thin

Thins non-null cells that denote linear features in a raster map layer.

  1. r.to.vect

Converts a raster map into a vector map.

Related Question