22

Our systems expect polygon shapefiles, representing a collection of non-intersecting and geometrically valid (Multi)Polygons. Specifically, farm fields. We often receive our representations of farms and their fields as polyline shapefiles containing the field boundary polylines, typically with some small geocoding errors like dangling ends.

Is there a reliable way to transform the polyline layer into a polygon layer, where the perimeters of the polygons are calculated as minimal loops around polylines in the shapefile? I understand I'll probably have to tidy up the polylines first.

I am primarily interested in solutions involving QGIS or other free tools since my company doesn't buy any of the professional packages.

Taras
  • 32,823
  • 4
  • 66
  • 137
Sam
  • 363
  • 1
  • 2
  • 8

2 Answers2

22

Converting lines to polygons will be easy: (Vector > Geometry Tools > Lines to polygons)

To deal with dangling ends, you could create a buffer around the polylines (Vector > Geoprocessing Tools > Buffer) and set them to 'dissolve'. This would attach any dangling endpoints to eachother.

Then convert the buffer polygons into lines (Vector > Geometry Tools > Polygons to lines)

Then convert the lines into polygons (Vector > Geometry Tools > Lines to polygons)

urcm
  • 22,533
  • 4
  • 57
  • 109
hamcake
  • 221
  • 1
  • 2
  • 1
    The polygons resulting from buffering the line are thin strips around the outside of each field. Turning them into polylines produces a double line at the perimeter of each field. I presume I need to get rid of a bunch of extra, overlapping polygons that result? Also, this doesn't seem to do much about dangles which are out in the open that should be snipped rather than snapped (because they have nothing to snap to) – Sam Aug 06 '12 at 01:06
  • This hopscotch answer was a huge help to a related problem. Thanks!!! – Katalpa Oct 16 '14 at 14:05
  • No Vector > Geometry Tools present in the default 2.18 – rovyko Apr 16 '18 at 02:39
13

For dealing with the dangle problem I suggest you try the Polygonizer plug-in, see here.

artwork21
  • 35,114
  • 8
  • 66
  • 134
nhopton
  • 6,983
  • 1
  • 19
  • 36
  • 4
    This comes now with the Processing Toolbox plugin -> QGIS geoalgorithms -> Vector geometry tools -> Polygonize – bennos Sep 30 '15 at 09:00