3

I have a vector layer with several polyline segments that represent borders of different areas. Each segment is connected to at least two other segments (at its start and its end). Some segments are connected to more then two other segments.

I need to convert those multiple polylines to multiple polygons. (See fig.)

enter image description here

When I use polygonize tool in vector->geometry menu it treats each segment as it's own polygon and makes garbage. (See fig 2)

enter image description here

Merging all segments into a single one doesn't help. Clipping large polygon with lines also doesn't help in this case since line segments doesn't cross the whole large polygon.

This problem seems obvious but I'm stuck. I can do it in GRASS with ease, but I have no idea how to do it in QGIS. I don't mind using Python scripting for this.

  • Can you perhaps use the Grass geoalgorithms in Processing > Toolbox > Grass ? – Martin Hügi Jun 24 '17 at 10:09
  • I can't use it since to do that I need to build topology for vector layer in GRASS style via v.build.topology. There is no such module int Qgis Toolbox. – Mihail Kondratyev Jun 24 '17 at 10:18
  • There is Polygonize tool in the QGIS Processing Toolbox - in QGIS geoalgorithms | Vector geometry tools | Polygonize. The failed one was probably Lines to polygons. – Kazuhito Jun 24 '17 at 11:42
  • This tool doesn't work in my case. I show result of polygonize tool on second figure. – Mihail Kondratyev Jun 24 '17 at 11:54
  • Ok. That works. I mingled Polygonize tool from qgis processing with vector>geometry tools>lines to polygones. Now I see they produce different results. Thank you – Mihail Kondratyev Jun 24 '17 at 12:12
4

Using QGIS processing: v.clean [snap]

Polyline test enter image description here

The threshold is determined by attempts: enter image description here

final results enter image description here

To get the polygons: polygonize

enter image description here

polygons enter image description here

  • My picture was schematic. All segments are already "snapped". The problem is in the next step. How can I convert those "snapped" polylines to polygones? – Mihail Kondratyev Jun 24 '17 at 11:06
  • I've completed the process, by processing, polygonizing – pigreco Jun 24 '17 at 11:57
  • i would recommend to add more lines in the "inner part" of your area. those three inner lines are supposed to be party of two polygons, right? so, if you start by adding parallel lines to those three inner ones and then try further to polygonize them. its also a problem to deal with those gaps. how is the line to polygon tool supposed to know how you want the lines to combine? its easier if there is at least one single line for each side of the new polygons. – DirkB. Jun 24 '17 at 12:03
  • Ok. That works. I mingled Polygonize tool from qgis processing with vector>geometry tools>lines to polygones. Now I see they produce different results. Thank you – Mihail Kondratyev Jun 24 '17 at 12:12

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.