# Buffer 1 to 1 relation in QGIS?

I have 2 layers ( geometric type - point), let's name it layer A and layer B. I need to find which points from layer B don't have their equivalents points from layer A. So i`ve made 10 meter buffer around points A and found which interestcs with points from layer B. So now I have a group of points from layer B which are intersected with buffers so they have equivalents points in A, and I can also find points from layer B which don't have equivalent points in A. But there is a chance that 2 buffers from layer A can intersect with 1 (the same) point from layer B. How can I find which 2 buffers from layer A are intersected to the same point. Or maybe on the other way - which point from layer B is intersected to 2 or more buffers?

The problem is in the 3 example, where 2 buffers are intersected to one point. How i can find that buffers?

I am using QGIS.

• What software are you using? If you're using ArcGIS you can use the Intersect (analysis) tool. Oct 10, 2016 at 5:14
• Im using qgis. Sorry I forgot to notice that Oct 10, 2016 at 5:22
• If, using your third example, that two layer A buffers intersect the same layer B point, would the layer B buffer intersect both layer A points? if so you could just use the layer B buffer and the tool 'Count Points in polygon'. Then its a simple task of querying back to those original Layer A points. Oct 10, 2016 at 7:58
• i thought about it too but there is a chance that buffer B won`t intersect with both points from A because its much closer to one of points. And if i set bigger buffer it might cover 3th point. We can say it works cause I know that there is more than 1 point but to be honest it`s not a perferct solution when I have 5k points or more. @edit and it also shows the relation 2-2 which is supposed to be correct. Oct 10, 2016 at 9:04
• You can see my approach with PyQGIS. Oct 11, 2016 at 16:02

You can do that by using PyQGIS. In the next code, 'combination' method from itertools module it does possible to search (avoiding repetition) features which are producing intersection in the buffer layer. Afterward, at the same loop, it can be searched if a point of second point layer is within the intersection area. Results, as features indices of buffer layer, are printed at the Python Console of QGIS.

``````import itertools

registry = QgsMapLayerRegistry.instance()

layer_A = registry.mapLayersByName('layer_A')
layer_B = registry.mapLayersByName('layer_B')

feats_layerA = [ feat for feat in layer_A[0].getFeatures() ]

feats_layerB = [ feat for feat in layer_B[0].getFeatures() ]

list = range(len(feats_layerA))

for i,j in itertools.combinations(list, 2):
if feats_layerA[i].geometry().intersects(feats_layerA[j].geometry()):
geom = feats_layerA[i].geometry().intersection(feats_layerA[j].geometry())

for feat_b in feats_layerB:
if feat_b.geometry().within(geom):
print "yes", i, j
``````

For testing my approach, I used shapefiles of next image where it is also observed, printed at the Python Console of QGIS, indices of features buffer layer whose intersection has a point of second layer.