4

I get polylines automatically generated from AutoCAD from a colleague. Converting them into polygons with QGIS 3.6, I find out some sliver polygons and gaps in between, as shown in the picture below :

Raw data

So far, I am correcting mostly by hand which is time consuming, as detailed follow :

To get rid of sliver polygons, I am using the command v.generalize from the GRASS Module, then remove the duplicated geometries and merge manually polygons with the same number.

To fill gaps, I am adding a new feature by clicking on the gap with the tool "Fill gapp with a new feature" from the digitizing tool plugin, and merge manually polygons.

Any of you have an idea to automate the process, or at least speed it up?

The aim is to get a result like this :

Expected result

3
  • In order to speed up the process, simply select and create problem polygons with a buffer, remove them from the main layer, then cut them with a layer with adjacent polygons, and then merge the two working layers into one again ... Commented Jun 24, 2019 at 14:53
  • Refer to this post. The top answer is for ArcGIS but there are QGIS/GRASS solutions further down: gis.stackexchange.com/questions/11004/… Commented Jun 24, 2019 at 16:44
  • You may want to look at the "v.clean.ogr" addon, it imports vector data into a GRASS vector map, cleans the data topologically, and exports them again using OGR library. See: grass.osgeo.org/grass7/manuals/addons/v.clean.ogr.html
    – markusN
    Commented Jun 30, 2019 at 20:55

3 Answers 3

1

First of all many thanks for your answers.

@Cyril I indeed do this to fill the gaps

@RGfromRWBJV I also use this tool to clean the layer

@markusN I also used this solution to clean the layer

There is no simple solution on this. Despite these functions, none of them are perfect.

Therefore the simplest way to do this is : - the snapping option from the cleaning/generalizing tool, - drawing a polygons covering the entire surface, using the symmetrical differences to generates the polygons and fulfill the "holes" in using the function "Eliminate Selected Polygons with the option "sharing the largest common boundary with the adjacent polygon"

0

I had the same problem some months ago, and overcame it used shapely and geopandas, here is my solution on github

It's a simple python Class that gets for every vertex the closest one in a distance you can define, if no vertex is within that distance it creates a new one and snap to it. You can execute with :

python auto_snap.py "path/to/layer.shp" Tolerance_value

the result is another shapefile with the polygons ( or even lines ) snapped to each other

1
  • Thanks for your reply. Unfortunately I do not know how to use it yet, could you describe how to use it? I definitely need to learn how to use and code simple script in python. Commented Jul 29, 2019 at 8:30
-1

Import your shapefile into Mapshaper. Click on the console button then in the console type -clean this will close any gaps and give you the stats on how those gaps have been closed. Then you can export your shapefile and use as required in whatever app you choose.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.