2

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

manually

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?

wollyka
  • 447
  • 3
  • 10

1 Answers1

2

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.

ThomasG77
  • 30,725
  • 1
  • 53
  • 93
Babel
  • 71,072
  • 14
  • 78
  • 208
  • I think you mean this https://gis.stackexchange.com/a/354691/99589 – Taras May 28 '21 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 '21 at 14:47
  • 1
    Let’s firstly wait for OP – Taras May 28 '21 at 14:50
  • I started following the workflow posted by Babel and I managed to create the centroid of the buildings downloaded: https://imgur.com/gUuVudt. I went to create the id-field using $id then in another try using osm_id. However, when creating the voronoi-polygon it is looking like a mess https://imgur.com/W0GqxE1. (using both $id and osm_id) I am sure I made a mistake somewhere. @Taras Does this method create clusters with a specific number of buildings/centroids (each cluster should have 30 close buildings)? Like already said, it looks similar – wollyka May 28 '21 at 17:20
  • Everything is fine, that's how voronoi polygons look like. Get yourself comfortable with the concept of voronoi polygons: https://en.wikipedia.org/wiki/Voronoi_diagram – Babel May 28 '21 at 20:37
  • Thanks.. The main polygon_layer is divided, however, it seems it is divided randomly. Some small polygon has 2 or 3 points/buildings inside them, others 10, others 1 etc... I don't need the small polygons to be the same size of course but they should have the same number of points/buildings. – wollyka May 28 '21 at 22:25
  • Please show your settings - after which step did you have this probelm? – Babel May 29 '21 at 11:45
  • Most probably the error is on step 3 (id_field): https://imgur.com/jRoLZdw . My layers settings: https://imgur.com/bK7KpbL . Buildings layer is the layer downloaded from OpenMaps and then converted to centroids Nabatiyeh is the layer that has the boundaries of the district (original polygon layer). Nabatiyé El-Tahta_Centroids is the layer that has the centroids from the Buildings layer. After Step 4 I get this : https://imgur.com/0gpFgHS . After Step 5: After union: https://imgur.com/a/KKHuqhb . – wollyka May 29 '21 at 14:30
  • OK, after step 5 seelct only those of the resulting polygons that overlap with your orginal polygon. Use Select by location. You should than have 1 polygon per centroid - however very unevenly as regards size because your buildings are unevenly distributed. – Babel May 29 '21 at 14:34
  • Ok but even after that some polygons gave like 1 -2 points inside them and others 3 etc.. I need them all for example to have 5 points inside each – wollyka May 29 '21 at 18:09
  • 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: https://gis.stackexchange.com/a/303657/88814 – Babel May 30 '21 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 '21 at 21:47