I am trying to filter out certain infrastructure from OSM data and convert everything to simple point layers using QGIS.

I have an OSM shapefile containing polygons of schools. In many instances, polygons lie within other polygons, for example, different faculties within a university building. However, if both polygons are categorized as university I just need one polygon with the university's name. (I don't need detailed data, just an overview). Converting every polygon to a point will result in multiple points for one single building.

So I am looking for a way to select the largest polygon and delete or merge the smaller internal polygons if they are within the same class. However, if there is a building containing a school and a kindergarten I want the polygons to remain separate.

I have tried the Select Within plugin to filter the internal polygons, but it obviously selects every single polygon, even the outer ones. The same goes for Select Layer by Location. For this, I have been working with a copy of the same layer.

Dissolving them isn't really an option either, since then I suppose I would have to preselect names first, since the name is not an attribute field and just can be found somewhere in the tags.

Just so you get an idea: I'm doing this for whole countries, so I need a way to automate this in a proper way.

Does anyone have an idea how to go about this issue?

Here is a screenshot of how the data looks. In this case, I want the MultiPolygon on the left to be merged into a single polygon with the label Technical University Munich.

QGIS school polygon layer


  • 1
    I see that it is OSM data, but can you maybe share your project with us?
    – Taras
    Nov 11 '21 at 18:35
  • 1
    My lovely TUM :) I am from the building 7 @_@ Did you try already the "Select by expression" together with overlay_contains() function?
    – Taras
    Nov 11 '21 at 18:43
  • Can you please extend your question with your efforts?
    – Taras
    Nov 12 '21 at 11:35
  • Thanks @Taras! I used overlay_within() instead and that did work, at least partly. It seems that the polygons which are not selected though this method are not entirely within the larger polygons, but go beyond them just a tiny bit. Haven't figured out yet how to solve this problem. Any idea on how to set a buffer during selection or set a percentage of the area which has to be within the polygon? Nov 12 '21 at 11:37
  • 1
    drive.google.com/file/d/1BIKCH8g2r8c-IL0V3PdESdcoofVyO2Hk/… Sure, here's the Google Drive link. It just has the school polygon layer in it. Nov 12 '21 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.