TransWikia.com

Automatically fill gaps and merge freshly generated polygons with the longest adjacent polygon

Geographic Information Systems Asked by Xavier Michael on October 21, 2020

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 Answers

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"

Correct answer by Xavier Michael on October 21, 2020

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

Answered by Hicham Zouarhi on October 21, 2020

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.

Answered by MapMan on October 21, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP