I have a polygon-layer with the boundaries of a district. I want to divide this polygon into several smaller polygons with each polygon having x number of buildings.

To do so, I added another (background layer with bing/google maps) and I started adding points in another layer (each point represent a building with automatic numbering). Then in another line layer, I draw manually the lines (around every x points/buildings) so that I can use later Split with line with the original polygon-layer


The method is working but it is time consuming. Is there a way to speed up the process? I found for example that OpenMaps can export the buildings shapes, but how can group each 30 buildings for example in a polygon?


1 Answer 1


A basic workflow looks like this:

  1. Download polygons for buildings using OpenStreetMap data with QuickOSM plugin.

  2. Create centroid for the buildings.

  3. On the centroid-layer, create an id-field for each of the points with the id of the original polygons they are located in. Use this expression: array_first (overlay_within('poly', $id)) (replace poly with the name of your polygon layer).

  4. Create Voronoi-polygons from the centroid-layer.

  5. Menu / Geoprocessing Tools / Union: voronoi-polygons with the original polygon-layer.

  6. Run Menu Processing / Toolbox / k-means clustering.

  • I think you mean this gis.stackexchange.com/a/354691/99589
    – Taras
    May 28, 2021 at 14:39
  • I see, yes, basically, it's the same as far as I can see, just with Union instead of Split with Lines - if you post this comment under the question, I can delete my answer.
    – Babel
    May 28, 2021 at 14:47
  • 1
    Let’s firstly wait for OP
    – Taras
    May 28, 2021 at 14:50
  • 1
    OK, than I mis-understood the question, I'm sorry for that: K-means clustering does not allow to set the cluster-size (a constant number of features to be grouped together). For this, see here: gis.stackexchange.com/a/303657/88814
    – Babel
    May 30, 2021 at 21:21
  • 1
    No worry. I have learned quite a few tricks and how voronoi polygons work! Looking at the link, it seems that I need R for the script/functions. Too bad I have only worked with SPSS/Stata as statistical packages (I don't know R and I don't have access to ArcGIS for the other solutions)
    – wollyka
    May 30, 2021 at 21:47

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.