5

In QGIS, I want to make polygons from a set of intersecting lines. Looking at the screenshot here, I want chop the purple line (it's a closed line, not a polygon) where it crosses the green and blue lines. The result hopefully would be a polygon where I have hatched in red. I have quite a few to do.

Polygonize problem

I have tried the QGIS tool previously called Polygonizer (see An Introduction to the Polygonizer Plug-in), but now called Polygonize. This is a tool that, given a layer containing a set of crossing lines arranged essentially like a # symbol, should create a polygon from the enclosed space in the middle.

(In QGIS 2.01, Polygonize is in the top menu bar: go to Processing -> Commander, then type "Polygonize" on the command line, select "Processing algorithm: Polygonize" from the list that appears, and press Enter.)

At the momemt Polygonize doesn't work properly. Is there another way to do what I want to do?

For example, wouldn't it be great if the QGIS 'Split Feature' command was able to work like MapInfo's 'Polyline Split', where you select the polygons to split, then select an already-drawn polyline to split by, and voila. But Split Feature seems not to work that way.


UPDATE: Detail of problems with running Polygonize.

I have 64-bit QGIS 2.01 installed to Windows 7 from the installer package, QGIS-OSGeo4W-2.0.1-3-Setup-x86_64.exe.

The routine processed an output from my shapefile, but did not create a polygon from the region enclosed by intersections between the blue, green and purple lines. (Note: in the actual input file, all these lines are on the same layer; the screenshot just colours them differently for illustrative purposes). What I got instead was a simple conversion of the purple outline to a polygon, as though the program completely ignored the blue and green lines.

When I node-edited the closed purple line, to open it so that I had a set of open crossing lines like in the # symbol, and then ran Polygonize again, nothing happened. No crash, but no visible polygon in the output file.

When I used Nick Hopton's own Laxton.kml data, I got a crash; see screenshot:

Laxton data crash

  • With things that appear to be missing, it often helps if you can tell us how you installed the tool (in this case, QGIS 2.0.1) and which operating system you installed it on. Perhaps you are hitting: gis.stackexchange.com/questions/72059/… but there is no way to be sure unless you provide more detail. – BradHards Feb 5 '14 at 10:54
  • Ok, yes, sure. Windows 7, installed 64 bit from the installer package, QGIS-OSGeo4W-2.0.1-3-Setup-x86_64.exe – IanS Feb 5 '14 at 11:09
  • Please edit the question, instead of putting key details in the comments. – BradHards Feb 5 '14 at 11:10
  • As you mention, the Polygonizer plug-in has been subsumed into the Processing Toolkit. Processing -> Toolbox and search on 'Polygonize'. I believe there are problems with this tool at present (under Ubuntu, at least) and would be interested in knowing if it works for you. – nhopton Feb 5 '14 at 12:38
  • 1
    Okay, looking at your recently added image: "Float division by zero". This is what I'm getting at the moment, the tool is broken. I was sent a new version to test, which requires a more recent version of Shapely, which I'll try to install but I'm not sure how to do this on Ubuntu. N. – nhopton Feb 5 '14 at 14:23
1

According to this Topic: How to go with...somewhat complex geological maps in QGIS? the polygonizing in QGIS 2.0 and 2.2 fails due to some problems with the shapely library. It is fixed in current QGIS Master (2.3.0).

Unfortunately, it does not work with QGIS 2.2.0 from the same OSGEO4W setup. So we have to wait for the stable QGIS 2.4. According to http://qgis.org/en/site/getinvolved/development/index#road-map this should be in June. So not far away.

1

The problems with 'Polygonize' appear to have gone away in recent builds of QGIS (in later builds of 2.4 and in 2.5).

Perhaps it's time for this topic to disappear too, rather than being bumped by 'Community' every so often.

  • 2.4 is now out. I just installed it and tried polygonize on a small test set. It still throws the divide by zero error. – Ian Goddard Jun 27 '14 at 21:28
  • In 2.4 installed using OSGeo4W, Polygonize (in the Processing toolbox) works fine. – underdark Sep 14 '14 at 10:41
  • @IanGoddard. Just checking Ian, you have installed Shapely? (python-shapely.) If not, you can install it using OSGeo4W. – nhopton Sep 14 '14 at 12:27
1

For getting correct results from the polygonize tool (which can be accessed via Processing > Commander) it is necessary that the lines intersect, this is also stated in the pdf file http://confound.me.uk/maps/ppv4.pdf

Polygonize extracts points where lines intersect and uses them, together with points from the original lines, to construct polygons

According to your errors using this tool I assume, that the lines of the triangle are not closed on every edge and the lines inside the square also do not intersect the square itself.

  • If indeed the lines have to intersect rather than just touch/meet, that would seem a slight deficiency in the tool, as I would argue that example B from @Eduardo should generate 4 polygons. I've come across a similar issue having just used the Polygonize tool for the first time and it's frustrating. – Gonja Sep 21 '16 at 10:34
0

In OPEN JUMP GIS there is a good running editing function which make polygons from a polyline network:

Polygonize... - all the enclosed areas inside crossed lines can be transformed in polygons. Optionally input data may be noded before polygonization (http://ojwiki.soldin.de/index.php?title=Tools)

You find a free Downloadlink here: http://openjump.org/

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.