3

I am trying to polygonize a line vector layer using "Polygonize" QGIS Geoalgorithm tool in PyQGIS. The polygon geometries are created successfully from the line features. But attributes of the line layer are not adopted to the created polygon layer upon polygonization. However, I have managed to adopt the attribute table's column headers from the input line layer to the polygonized layer using this command.

processing.runandload("qgis:polygonize",line_path,True,False,polygon_path)

How to transfer the attribute values of the input line layer to the created polygon layer during polygonization process using the 'Polygonize' tool?

  • Have you tried the Lines to polygons tool which is quite similar? The command would be: processing.runandload("qgis:linestopolygons",line_path,polygon_path) – Joseph Nov 10 '16 at 10:48
  • Thanks for the suggestion @Joseph. I had tested polygonization using Lines to polygons tool. I am able to get the attributes in this case but the geometries are not properly formed as desired. Instead it produces sliver polygons as shown in this post – Sjs Nov 10 '16 at 11:57
  • Ahh I remember that post, you might be able to remove those sliver polygons using the v.clean tool but don't have any shapefiles with sliver polygons to test. – Joseph Nov 10 '16 at 12:13
  • I have uploaded the line shapefile in this link. You may have a look at it @Joseph – Sjs Nov 11 '16 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.