7

Through a "dissolve" process in QGIS, I achieved some defective polygons generated after dissolve process that have some fails, like these in the screenshot:

example

Is there any automatic process I can make in QGIS to remove those lines inside the polygon and leave only the outer borders? I can manually delete using the "Node Tool", but I was looking for an automated solution.

The polygon seems to be closed, as it can be seen:

Selected polygon, with defective lines

4
  • 1
    I assume those lines are inner rings, so this might help you with some python code: gis.stackexchange.com/questions/113284/…
    – AndreJ
    Commented Jul 27, 2015 at 9:25
  • 2
    Did you already try the GRASS v.dissolve from the toolbox? Normally this is faster and produces less errors. For removing artefacts, try v.clean with e.g. rmarea
    – Bernd V.
    Commented Jul 27, 2015 at 10:40
  • 1
    Have a look to this discussion: gis.stackexchange.com/questions/154598/…
    – Sergio
    Commented Jul 27, 2015 at 11:04
  • Thank you so much! I'll study all these proposals and then report which worked better for me.
    – Alan Tygel
    Commented Jul 28, 2015 at 10:10

4 Answers 4

12

You can use the QGIS-Processing tool Delete holes for that.

Just pass the polygon layer with holes, the algorithm will remove all inner rings (aka. holes) for each polygon automatically.

2
  • I had to use the tool several times on the cleaned output again to get a good result. Did not remove 100% by this procedure but around 90%
    – joaoal
    Commented May 2, 2019 at 8:50
  • It depends on your use case. In the question, these were generated by the dissolve tool, so they are holes. If they weren't holes but other small polygons, this is not the tool for the job. So, it's not a tool for all cases. Commented Nov 8, 2019 at 12:23
2

This happens often often to me when dissolving polygons. The only reliable and easy way that I found was to buffer the polygons with a minimal distance that is still acceptable for you (e.g. 0.001 meters).

0

I have a solution that is applicable in a small scale project and doesn't involve programming of any sort.

Probably someone already figured this, but I'll take my chances:

1) Create an ID on the original, damaged layer

Creating an ID attribute is simple, but so is my solution, so I'll go over it. creating an ID attribute on field calculator

First, you have to open your attribute table and then go to the Field Calculator, which is a button pretty much like an abacus. There, you will be given the option to create a new field or update an existing one. On the picture above I'm creating a new one called "ID". The formula is right at the end of the picture. (Sorry for having my QGIS set up in a different language. Since the design and the formulas are exactly the same throughout the language versions, I don't think it will get in our way here.)

Attribute table

2) Convert the polygons to lines

This step is located on the Vector > Geometry section the the menu. Your converted shape should look like this:

Polygons converted to lines look like this Right after converting the polygons to line, you will have to do the exact opposite, which is...

3) Convert lines to polygons

The options are right next to each other. Again, let's not mind the language barrier here. Do not mess the order here!

4) Rejoice The reason you did steps 2 and 3 is because now you're sure those lines will be considered as polygons, which means they now have their own line on the Attribute Table. If you check it out, it will look like this:

An Attribute Table ready to face some manual deletion process!

The first one is ALWAYS the entire polygon (trust me, I've deleted a couple hundred lines today...) and the rest are the loose lines in the middle. You can enable editing and get ready for action. If you decide to try this, two things that you should keep in mind are: organize your table ID-wise, this way you're sure you're not missing anything and use shift to select clusters of data, just like any other program.

I'm aware this is not the crème de la crème of QGIS problem-solving, but if you're facing a situation where the tools are not working because of the invalid geometries these lines create (I even tried dissolving by the ID instead of deleting manually, but it didn't work), then this might be a way out.

1
  • 1
    Your image links are no longer working. Can you move them to another site perhaps? Commented Aug 24, 2017 at 22:07
0

The "deleting holes" option from QGIS was also deleting the wholes I did not want to be deleted, so instead I ran a buffer of a few cm to remove those lines.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 6, 2023 at 14:48

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.