I have a similar question to: How to join lines in QGIS for later using "lines to poly"?

I have a line shapefile that I wish to transform into a polygon shapefile. After making some cleaning and closing some gaps, the lines have this look: Original shapefile (lines)

After that I've made "Vector>Geometry Tools>Lines to Polygons" but I've got this: Transformed shapefile (polygons)

I've made a detection for dangles... and I found a few on the places that seems to have that kind of error. Also... the location of those points, seems to be on the places the "lines to poly" process fails. I've tried to edit some of the dangles, snapping them to the nearest point to make sure there were no gaps... but running again the dangles detection, they're still there. This is how all the shapefiles (plus the dangles) look like: Shapefiles (lines+polygons+dangle detection

Is this easy to fix without "going to the grass"? Why don't the dangles disappeared after snapping them to the correct place?

EDIT 1: I was able to clean all the dangles... I was not happy with the snapping... and I've retried once more. I guess I was trying the wrong ones... I tried a very simple one... and one by one I was able to solve the more complex dangles, some were overshoot lines that were behind other segments and other were the intersections. Well... after that, I was able to clean all the dangles!!!! :D

Now for the bad news... I got an error while making the Lines to Polygons:

An error has occured while executing Python code:

Traceback (most recent call last):
  File "C:\PROGRA~1\QGISCH~1\apps\qgis\python\plugins\fTools\tools\doGeometry.py", line 348, in run
    success = self.lines_to_polygons()
  File "C:\PROGRA~1\QGISCH~1\apps\qgis\python\plugins\fTools\tools\doGeometry.py", line 519, in lines_to_polygons
    if inFeat.geometry().isMultipart():
AttributeError: 'NoneType' object has no attribute 'isMultipart'

Python version:
2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

QGIS version:
2.4.0-Chugiak Chugiak, 8fdd08a

Does this ring any bells to you guys?

(by the way... the first question was about the dangles... now it's about the lines to polygons process, however... the question is "Can't transform lines to polygons" should I close this and start another or may I continue here?)

EDIT 2: user30184 asked for the Layer (no dangles at the moment): Lines shapefile

  • Possible duplicate of: gis.stackexchange.com/questions/93369/… There seems to be no easier way.
    – AndreJ
    Commented Oct 17, 2014 at 9:49
  • @AndreJ I've updated my question... I've get rid of the dangles... but, now I can't get the lines to polygons to work. :P
    – Fernando
    Commented Oct 17, 2014 at 10:18
  • 1
    Have you used the Polygonize Command from Processing, as mentioned in the linked answer?
    – AndreJ
    Commented Oct 17, 2014 at 10:20
  • Can you share you shapefile?
    – user30184
    Commented Oct 17, 2014 at 10:28
  • @AndreJ I didn't, but after your question I've tried Polygonize instead of the "Lines to Polygons" and I also got an error:Algorithm Polygonize starting... Processing lines... 'NoneType' object has no attribute 'isMultipart' See log for more details
    – Fernando
    Commented Oct 17, 2014 at 10:30

3 Answers 3


So... I'm answering my own question. I'm just selecting my answer because it's not using GRASS and, at the moment, I'm trying to stick to the QGIS environment (in the future, I'm almost sure I'll need to invest more in GRASS).

So... this is what I've did:

  1. I selected the select attributes by rectangle enter image description here
  2. selected my whole layer enter image description here
  3. Opened the layer attribute table, where I found this: enter image description here
  4. Then turned into edit mode, inverted the selection, deleted those 2 attributes (ID 104 and ID 106), saved and exited edit mode. The table became: enter image description here
  5. After that... just needed to run Poligonize: enter image description here
  6. And... here it is, the final result: enter image description here

Resuming... it was not the "save as" that corrected the layer. It was those 2 attributes (some kind of trash from previous handling of the shapefile) that were corrupting the file logic, after removing them Polygonize was able to run without any kind of trouble.


Cleaning the original shapefile using GRASS v.clean snap from the Processing Toolkit (using a Threshold of 10) produces a line shapefile that can be polygonised using 'Polygonize' also from the Processing Toolkit.

enter image description here

  • I was trying to get away from GRASS... just because it's something I'm not very used to. I'll try to test your solution as soon as possible. However I was able to use the Polygonize after making a copy of the shapefile (Save As). Thanks for the help!
    – Fernando
    Commented Oct 17, 2014 at 14:29
  • GRASS and I don't get on either, but you can use these functions within QGIS: Processing -> Toolbox.
    – nhopton
    Commented Oct 17, 2014 at 18:00
  • I found a way to solve this... I'll post some pictures showing how I've done it in a while.
    – Fernando
    Commented Oct 20, 2014 at 8:47
  • Actually, what you did was very sensible. ogr2ogr (used in QGIS via "save as..") is good at repairing some sorts of broken shapefile.
    – nhopton
    Commented Oct 20, 2014 at 9:35
  • please check my answer... it was not the "Save As". I tried to recreate later the proceeding and it didn't work. It was the removal of 2 attributes. Many thanks for the help.
    – Fernando
    Commented Oct 20, 2014 at 10:28

I too faced similar problem when trying to polygonize lines using the "Lines to Polygons" tool. Obtained sliver polygons similar to the above images. But when I tried polygonization using "Polygonize" tool from the Processing Toolbox, got the exact desired polygons. Refer this link

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.