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.


6 Answers 6


The "Polygonize" tool from the Processing Toolbox (Ctrl+Alt+T) 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).


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


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 was created. A warning appeared:

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

I discovered the gaps 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

  • Everyone should know about topology checker :) For those who can't find it, it is a core plugin that is turned off by default (at least for v3.26). Commented Aug 18, 2023 at 15:54

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


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 and acknowledge you have read our privacy policy.

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