0

enter image description here

I need to vectorize the raster by keeping one center line trough the boundary pixels. My solution would need to be very similar to this question: Converting raster to vector by generating center lines?

I tried the provided solution.

Replace all no data values:

from qgis import processing

expression = "if(A>0, 1, null())"
input = "input_raster.tif"
output = "mapcalc"

parameters = {
    "expression": expression,
    "a": input,
    "output": output
}
processing.run("grass7:r.mapcalc.simple", parameters)

This returns a black image, the issue might be with the expression?

Thin raster layer to thin non-null cells:

from qgis import processing

input = "mapcalc"
output = "thinned" 

parameters = {
    "a": input,
    "output": output
}
processing.run("grass7:r.thin", parameters)

Raster to vector conversion:

from qgis import processing

input = "thinned"
output = "centerlines" 
type = "line"

parameters = {
    "a": input,
    "output": output,
    "type": type
}
processing.run("grass7:r.to.vect", parameters)
0

0