Aggregating features values based on distance in QGIS

aggregationdistance matrixfield-calculatorpolygonqgis

In a polygon dataset, I try to summarize values of surrounding features based on a minimum distance if their area is too small (e.g. 500 square meters).
For example, I have 3 polygons with 300, 250 and 450 square meters that sum up to 1000 square meters. They might not need to touch each other so using aggregate() for features that tough each other is not possible.

enter image description here

The area of the selected (yellow) features should be aggregated to a total sum. The violet points represent the centroids.

I already tried via a distance matrix (based on the centroids of the polygons) to find out the distances between the centroids of each polygon feature. My consideration was that I can join the distances between the polygon centroids to the polygons, then filter for small distances (e.g. within 50 meters) to identify polygons that lie within this 50-meter threshold and then aggregate them via an id field. However, this resulted in a 1 to n join (or a value relation) because every single centroid has n-1 distances to all other centroids in the dataset.

I can't figure out how to aggregate the values. I also need to integrate the workflow into a graphical model. Any suggestions on how to start?

Best Answer

Let's assume there is a polygon layer called 'grid_test' with nine features in it, see image below.

input

Step 1. Apply the "Centroids" (This step you already did)

step_1

Step 2. By means of the "DBSCAN clustering" get those groups within a 50-meter threshold

step_2

Step 3. Use any preferred method to aggregate the values based on newly created "CLUSTER_ID" field. I deployed the "Aggregate".

step_3

and finally get the output

output

Related Question