I would like to convert all values having the value 1 in a binary raster to a line vector layer. The following image shows the binary raster (1=white
and 0=black
):
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 GIS r.to.vect), which creates polygons and thus two lines, where I need only one:
r.thin
?r.mapcalculator
does not produce any result, I didn't succeed yet in setting a nodata value with 'gdal_translate', so `r.thin' only produces one line of pixels. Also I am now asked to avoid GRASS modules. Converting a raster to a line vector seems such a 'normal' geoprocessing issue to me that I thought it might be worth asking if there is already something available. The white pixels are just one pixel wide, not sure if you mean that.