The optimal output would look like the red lines in the following image (which I realized by modifying the GDAL script raster to vector line):
However, this is very slow and not applicable on large rasters. Is there a similar open-source implementation (callable in Python) that does the same with less processing time?
Would it decrease the processing time of the GDAL script raster to vector line when writing each single wkbLineString to a shapefile instead of adding them all to a wkbMultiLineString before writing them to a shapefile?
The only related posts I found so far are referring to polygonizing the raster (which I realized with GRASS r.to.vect), which creates polygons and thus two lines, where I need only one: