2

I have a large layer with a couple of thousand polygons mapping inland waterbodies. A lot of these contain rings, mapping islands. I would like to count the number of islands and do some statistics with them. I vaguely remember that there was a tool that could automatically fill such rings with new polygons in QGIS 2.X, but it appears to be missing in QGIS 3.X. I did not find any plugin to do this job either. Is there any tool I have been missing, or can you point me to a different solution?

Edit: Please note that I want to do this automatically - I know, that I can fill rings by hand, but that won't do for thousands of them.

C.-F. Vintar
  • 1,608
  • 13
  • 25
  • 1
    Not all interior rings of a water body must be an island. Can be water bodies inside an island too. But you can count interior rings with the num_interior_rings($geometry) expression in the Field Calculator. – Gabriel De Luca Jan 13 '20 at 04:28
  • For filling the rings with new polygons, see: https://gis.stackexchange.com/questions/308659/creating-polygon-from-hole-in-qgis. – Gabriel De Luca Jan 13 '20 at 04:32
  • @GabrielDeLuca Thanks for your first comment. That is at least a way to get the numbers. In the case of my data, the rings within the water bodies are islands. New water bodies would be represented by an additional polygon. Also, I think in this area, this is pretty rare. The link of your second comment only offers ways to do this manually. I know this tool, but it is just not an efficient method for large data sets. – C.-F. Vintar Jan 13 '20 at 07:33

1 Answers1

2

Found a rather dirty solution, but it does the trick. If anyone knows a more elegant way, please feel free to share. If not, this may be worth turning into a small script/plugin?

1) Take the polygon layer (for the test I took only about an eighth of my original data. Section from the original polygon layer showing water bodies in central Europe.

2) Draw one new polygon on a temporary layer, the polygon covers the entire area of the original layer. I put it behind the other layer here for clarity. One polygon covering the entire extend of the input.

3) Run the Difference-Tool from Vector > Geoprocessing Tools. Use the Temporary layer as the input layer and the original data as the overlay. This will result in a large polygon with rings representing former polygons, and inner polygons representing former rings. This is one multipart polygon though. Original water bodies cut out of the large polygon. The rings from the original remain as polygons.

4) Run the Multiparts to singleparts tool from Vector > Geometry tools on the difference layer. This will result in splitting up the one multipart polygon. Now you can delete the one large polygon that represents the "rest" of your first temporary layer. What remains are single polygons where your original layer shows rings. Sample with former rings now represented by polygons.

C.-F. Vintar
  • 1,608
  • 13
  • 25