While trying to polygonize the polyline layer in PyQGIS using


command in python console, it does not create polygons corresponding to the line edges. Instead it creates sliver polygons along the curved edges. Why the polygons are not created along the line edges?

enter image description here

On polygonization, the black lines are supposed to be the edges of the created polygons. Instead only few slivers are created along the curved edges(blue polygons).

  • Have you tried the SAGA version of the tool: processing.runandload("saga:convertlinestopolygons",explode_path,polygon_path)
    – Joseph
    Commented Sep 23, 2016 at 9:19
  • @Joseph tried the SAGA version just now. Still the result is same.
    – Sjs
    Commented Sep 23, 2016 at 9:51
  • 1
    Try cleaning your line shapefile with the plugin Geometry Checker or the GRASS tool v.clean.
    – Joseph
    Commented Sep 23, 2016 at 13:04
  • 2
    @Joseph the data is topologically clean. Got the desired result using 'Polygonize' tool. Thank you for the comments. Have come to know about couple of topological checkers :)
    – Sjs
    Commented Sep 23, 2016 at 15:00
  • Nice one, glad you found the solution =)
    – Joseph
    Commented Sep 23, 2016 at 15:33

2 Answers 2


Got the exact polygons as desired using the 'Polygonize' algorithm (Processing Toolbox --> QGIS Geoalgorithms --> Polygonize) in the python console.

import processing
polygon_path = "C:\\Documents and Settings\\User\\polygonsFormed.shp"
line_path = "C:\\Documents and Settings\\User\\inputLine.shp"

Had the same problem while using the 'Lines to Polygons' tool available in Vector menu. Got lot of little sliver polygons even though the data is topologically correct.


QGIS geoalgorithm available in the processing toolbar worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.