7

I have a couple of messy polygon boundaries (example data) that should share a boundary but don't:

enter image description here

I've had a look at some suggested tools for a similar issue using ArcGIS in a separate question but need some sort of method for QGIS (or another FOSS4G solution).

Some possibilities:

  • v.clean with 'snap' only seems to work on lines (so perhaps a polys-to-lines + v.clean/snap + lines-to-polys might work?);
  • a combination of geoprocessing steps, perhaps buffering each polygon (filling the gap) then intersecting them?
  • I think there is no direct tool in QGIS, it is pretty difficult geometric problem. It is not that much snapping what you want to do in this case because on the picture you have two polygons with completely different node frequencies. If as much automatic as possible I would start playing with filling gaps and after that removing sliver polygons. I am not writing this as answer because at this moment can't tell what are the possibilities of direct QGIS and included GRASS and SAGA tools to achieve this. – Miro Aug 25 '15 at 9:53
  • You're right - I've changed the focus of the question somewhat (regarding filling in the area), it was too limiting to label it as a 'snapping' issue. – Simbamangu Aug 25 '15 at 14:37
  • This could be done in Safe FME, but I don't think there is an out of the box free solution. The workflow would be to snap the geometries to the closest vertex in the other line, then densify the geometry, and re-snap and densify and re-snap until a suitable level was achieved and then remove overlapping nodes.. I think this would require a python script in QGIS, or Safe FME, which has the snapper and densify tools. – HeikkiVesanto Aug 25 '15 at 14:45
  • How many polygons you have? I mean if you want/need to keep that more detailed boundary you will always have to do this job as semi-automatic. I have an idea how to do this for relatively smaller number of polygons I am going to write as answer. – Miro Aug 25 '15 at 23:15
  • At the moment - 3-4 polygons, but there is a nationwide dataset (with dozens of complicated boundaries) which I'll be getting onto soon, so the more automatic the better. – Simbamangu Aug 26 '15 at 8:02
5

If the number of polygons is relatively smaller and you prefer to keep the more detailed boundary I would probably make it semi-automatic way as following:

  1. remove the overlaps of less detailed polygon with Clipper plugin - you select more detailed polygon and use clipper which will remove all overlaps of other polygons.

  2. use AutoTrace plugin to quickly create polygon following the more detailed boundary, filling all gaps between the two adjacent polygons and safely overlaping the less detailed polygon - I believe in most cases this should take only few clicks

  3. Using Merge selected features tool from advanced digitizing to merge the autotrace polygon with the less detailed polygon

I know this is not automatic but I believe if you want to follow the more detailed boundary there will always be need to use some semi-automatic approach and this is just few clicks per polygon which I think might be sufficient enough in many cases.

  • That's looking pretty good - Autotrace does take a long time to use though and often misses vertices along the way. – Simbamangu Aug 26 '15 at 8:21
  • @Simbamangu Well it can get better with time once finding the optimal tempo but yes, it will always take some clicks and time. Not sure what you mean by missing vertices, I have never seen in my experience that it would miss some vertice on the line between where I started and ended, but I might have missed some because I didn't expect it could. – Miro Aug 26 '15 at 9:38
  • I ended up using a slightly different method but this workflow got me started - thank you! I'll edit my question with the solution later. – Simbamangu Aug 27 '15 at 11:01
2

It can be solved by GRASS or QGIS GRASS plug-in. See: https://grasswiki.osgeo.org/wiki/Vector_topology_cleaning

Step by step (GRASS 6.4) 1. Start GRASS with GUI

grass -gui

  1. Create a new location pushing Location wizard button. Select projection by epsg (32736) You needn't set up default region extent.

  2. Press Start GRASS session button (the new location should be selected, PERMANEN mapset is OK)

  3. Import your shape file

v.in.ogr dsn=/path_to_file/polygon_gap.shp output=polygon_gap snap=2000

(I measured the widest gap (about 2 km) before for the snap parameter)

5.Export cleaned data to shape

v.out.ogr input=polygon_gap type=area dsn=/path_to/polygon_clean.shp

Result

  • Could you give some workingq examples of the workflow, using the sample data I've posted? I have tried several of the v.clean options without success. – Simbamangu Aug 26 '15 at 8:03
  • 1. Start GRASS with GUI – Zoltan Aug 26 '15 at 19:04
  • Interesting - the result you give does seem to solve the 'closing the gap' problem, but if I run v.clean from the Processing toolbox it does not give the same result! – Simbamangu Aug 27 '15 at 10:59
  • Can you set snap in the processing toolbox? Wich version of GRASS is used by the toolbox (GRASS 7 or GRASS algorithms)? – Zoltan Aug 27 '15 at 19:49
  • Yes, I can set the snap tolerance but it doesn't seem to have an effect. GRASS 6 in QGIS 2.8.2 – Simbamangu Sep 5 '15 at 8: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.