I got a point-layer Points where all points lying exactly on the vertexes of the polygons of a polygon-layer Polygons.

How do I join all numbers of the point-layer to the polygon-layer?

All algorithms I used didn't really work (NNjoin, MMQGIS, select attributes by location etc.).

What I need is to bring the column Nr into multiple columns of the polygon-layer like Nr_1, Nr_2, Nr_3, Nr_4. To bring it into one column like including a separator would also work.

I'm running QGIS 3.16.3.

enter image description here

  • For all results in 1 column, see this post
    – JGH
    Commented Aug 20, 2021 at 11:02
  • Also 1 and 2
    – Taras
    Commented Aug 20, 2021 at 11:04
  • @Taras: In my case the output is for all three polygons the same: '1194,196,1195,193,1193,1196,11'
    – thompson82
    Commented Aug 26, 2021 at 5:40

1 Answer 1


You can achieve what you want e.g. by running custom PyQGIS script in QGIS's Python console. First, open attribute table of the polygon layer and create a new column to it (named here as ListOfNrs). Second, go to Python console (Ctrl+Alt+P), open script editor, paste the following code in it and press the green triangle to execute the script.

mapcanvas = iface.mapCanvas()
layers = mapcanvas.layers()

# Assuming that first layer contains point data
# and second layer contains polygon data

for a in layers[1].getFeatures():
    temp = list()
    prov = layers[1].dataProvider()
    targetfield = layers[1].fields().lookupField('ListOfNrs')
    for b in layers[0].getFeatures():
        if a.geometry().intersects(b.geometry()):
    temp2 = ",".join(temp)
    atts = {targetfield: temp2}
    # call changeAttributeValues(), pass feature id and attribute dictionary
    prov.changeAttributeValues({a.id(): atts})
  • it works well if both columns 'Nr' in Layer "Points" and 'ListOfNrs' in Layer "Polygons" are strings. Is there a possibility to extend the code by a buffer if the any point is not exactly on the vertex of a polygon? THX for great help by now
    – thompson82
    Commented Aug 26, 2021 at 5:40

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.