Skip to main content
5 of 5
added 53 characters in body
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Polygonizing LineString features to Polygon features and keeping Attribute table values using PyQGIS

I am trying to create a circular raster in Qgis3.8.3-Zanzibar with the Python console. I am able to make it with LineStrings (combine of Polyline and Circular String) and fill each feature with attributes (see picture).RadarRaster

Attribue table of LineString Layer

Now I want to make each feature to a polygon. Therefore, I use the function polygonize (Processing Toolbox --> QGIS Geoalgorithms --> Polygonize). I check the "Keep table structure of layer" option and run the process:

Processing algorithm…
Algorithm 'Polygonize' starting…
Input parameters:
{ 'INPUT' : 'LineString?crs=epsg:25832&field=id:integer&field=name:string(20)&field=WINKEL:integer&field=METER:integer&field=KILOMETER:Double&field=AREA_METER:Double&index=yes&uid={feb5e364-45f5-4e97-aeee-7ab4cd65bbf3}', 'KEEP_FIELDS' : True, 'OUTPUT' : 'TEMPORARY_OUTPUT' }
Processing lines…
Noding lines…
Polygonizing…
Saving polygons…
Execution completed in 0.98 seconds
Results:
{'OUTPUT': 'Polygons_from_lines_9dcc9791_d9e2_4399_b9ff_3bf1c61f6e1c'}
Loading resulting layers
Algorithm 'Polygonize' finished

Ok it works... all features are now polygon. But all the attribute table values are gone.

polygon attribute table no values

How do I keep the attribute values? And why did the polygonize function give all the new polygon features random ids? It is impossible for me to give them new values because there are distributed random, not like before when I add the as LineStrings.