4

I am a little new to QGIS (using v.2.18.0 La Palma) so perhaps someone can help me out. I am trying to find some faulty topology and understand the conversion from polylines to polygons.

I created five shapes with polylines in QGIS to demonstrate the problem and issues. I intended to post images demonstrating the issues I am having. However, this question/message board will only allow me to post two links. So, unfortunately, my description below will not be quite as clear as it would have been had I been able to post the images I can't post. You will have to go to the link at the bottom of the page to see all of the images.

In the images you will find the following shapes:

  • Upper Left: 1 polyline (closed)

  • Upper Right: 12 polylines (closed)

  • Middle: 17 polylines (closed but complex with many vertices)

  • Lower Left: 1 polyline (open)

  • Lower Right: 4 polylines (open)

The middle shape is really the one I am trying to convert to a polygon using either the Polygonize or Lines to Polygons tool, neither which seems to work for me. I ran the Topology Checker to look for dangling ends and the results are shown in the image below taken from a screenshot (dangling ends shown with red dots). I expected errors on the lower shapes because I know they have open ends. However, I cannot figure out why the middle shape has dangling end errors. I have snapped the ends of the lines together and when I zoom in, I cannot find any overshoots or undershoots. What else would cause the dangling end errors?

topology checker results

I ran both the Polygonize Tool and the Lines to Polygons Tool on these shapes. For the Polygonize Tool, both the upper closed shapes create polygons, regardless of whether they consist of one polyline or 12 polylines. The lower open shapes do not create polygons, though that doesn't surprise me. The middle shape also does not create a polygon, which I assume has something to do with the "dangling ends" errors that I can't find.

For the Lines To Polygons tool, only the shapes with one polyline are converted, regardless of whether it is closed or open. The shapes with multiple polylines do not convert, though I don't know why the closed shape in the upper right will not convert. I am at a loss to explain the partial results for the middle shape other than I presume it has something to do with the dangling ends I can't find.

The images I couldn't post and a zip file containing the QGIS project file and .shp file that created the above images can be found here: http://brucewiland.com/download/

Can anyone tell me how to find and correct the errors in the middle shape that would allow it to be converted to a polygon?

I would also be interested in how and why the Polygonize and Polylines to Polygon tools give different results i.e.when do you use one over the other?

  • I used the OpenJump Topology Network checker to snap the endpoints of the middle polylines (17). Afterwards, QGIS Polygonize correctly created a polygon from the lines. – klewis Nov 14 '16 at 20:13
  • @klweis, where do you find the OpenJump Topology Network checker? – Bruce Wiland Nov 16 '16 at 3:26
1

Your middle polyline has a topology error at (-97.6073 32.0222). Unfortunately, you only see it at a scale of 240:1, and you need to move the vertex away from the underlaying line to see and delete the bad line. The topology checker does not notice it, because every single line is topologically correct, only merging to a closed ring is not possible.

Apart from that, the polygonize tool works best with intersecting lines, but not on open rings. Polygons from lines is able to close one-part open lines, but fails on more complex geometries.

  • was there a tool you used to find that topology error? I found that bad line after you told me where it was, but I have no idea how you found it. – Bruce Wiland Nov 20 '16 at 13:50
  • I used the OpenStreetMap editor JOSM. They have better tools to connect lines to a closed ring relation. I got the ring closed, but one element was still pending outside. – AndreJ Nov 20 '16 at 17:56
1

As @AndreJ mentioned, the middle line is not closed due to the vertex. You would need to snap this vertex which can be done automatically using the v.clean tool from the Processing Toolbox. I used the parameters as shown in the image with a threshold of 0.001:

v.clean

Then I ran the Polygonize tool which gave the following result (your middle line is converted to a polygon):

result

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.