I have a shapefile with city areas, but unfortunately the shapefile only contains single lines. The shapefile looks like this:

enter image description here

I want to convert those lines to an area-polygon shapefile in QGIS. I tried it with the "Lines to polygons" tool (Vector > Geometry Tools > Lines to polygons), but it didn't work correctly. After using this tool, the shapefile looks like this:

enter image description here

Is there any other way to convert the line shapefile to an area polygon shapefile in QGIS?

I am using QGIS 2.14.3 Essen.

  • 3
    I got something similar the last time I used that tool. I was able to get polygons by using the polygonize tool.
    – johns
    Aug 18, 2016 at 16:47
  • 1
    Thnaks for your answer, where can I find the polygonize tool?
    – Mark White
    Aug 18, 2016 at 17:18
  • 1
    Polygonize can be found here - Processing Toolbox, QGIS geoalgorithms, Vector geometry tools.
    – klewis
    Aug 18, 2016 at 17:27
  • 1
    I tried it, but when I run the polygonizer I get an empty shape file :-(
    – Mark White
    Aug 18, 2016 at 18:04
  • 1
    Can you upload the shapefile to dropbox or similar?
    – AndreJ
    Aug 19, 2016 at 6:48

6 Answers 6


The "Polygonize" tool from the Processing toolbox still works fine for me on simple lines:

enter image description here

It is however necessary that the lines intersect, or share common vertices. And lines should have no self-intersection.

You might need to snap the corner vertices to get it working. I usually set the snapping tolerance to 10 pixels to the vertex.


Just a hint if you can't find the Polygonize tool. In my QGIS 2.18.3 installation (Windows) I could not find the Polygonize tool at Vector geometry tools within the Toolbox. It took me some time to realize that I needed to install the python-shapely library with OSGeo4W (thanks Nick Hopton : Perfect Polygons in QGIS).

  • Thank you! I was confused for a long time because out of the box QGIS on Windows has a polygonize tool that's only for rasters. Another step that may or may not be necessary is to enable QGIS Geoalgorithms under "Processing >> Options >> Providers" Jun 26, 2017 at 0:54
  • Thanks for this answer. I thought I was going crazy not finding it anymore...
    – gisnside
    Jan 12, 2018 at 16:30

If the polylines overlap each other, Polygonize tool cannot handle it as follows:

enter image description here

However Lines to polygons tool works as expected as follows:

enter image description here


Looking at your image I would assume that each line does not fully encompass an area, the lines are just acting as fences and not reconnecting back at the beginning. Your polygons are being created from the ends of the lines so the 'lines to polygons' tool is working fine, its the data thats the issue.

I'm afraid the only you can do that I can think of is to digitise a new layer of polygons. Thankfully QGIS has made that really easy with the trace digitising tool (a magnet icon) which is available in 2.14


I had the same unwanted output and after doing some research it seems the cause can vary.

My case was I had some polyline layers with very, very small gaps (in which some fragments were formed by two or less nodes) (Figure 1 and Figure 2).

So, after directly running Lines to polygons tool, the algorithm would run, but no polygon would be created. A warning would appear:

One or more line ignored due to geometry not having a minimum of three vertices.

I discovered them by running Topology Checker ('Must not have dangles' rule) which would result in multiple 'dangling end' errors (Figure 3).

I fixed it with the following steps:

  • Converting the lines to points (Extract vertices).
  • Converting back points to lines (Points to path), setting the 'Order field' parameter as 'Vertex index'.
  • Converting the lines (paths) to polygons (Lines to polygons).

Using QGIS 3.14.1 version.

Figure 1. Polyline in map canvas after loading the layer.

enter image description here

Figure 2. A very, very small gap (zoom+ is at maximum).

enter image description here

Figure 3. Errors appointed by the 'Topology Checker' tool.

enter image description here

  • 2
    Perfect idea! Would it be possible if you add some graphic to your answer ? I am curious about your initial lines 😊
    – Taras
    Mar 17, 2021 at 5:03

If there are no holes, I would create a scratch layer with a single polygon big enough to cover your whole area. Then I would intersect it with your lines-to-polygons result and split it further as necessary.

Your Answer

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

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