1

I have a polygon layer and a point layer. I want to get the attributes from the point layer and join them to the polygon layer in a one-to-one relationship. This is normally easily done with the Join attributes by location tool but it doesn't work here as the polygons are overlapping.

What i have is polygons that are an exact copy of them selves but their attributes are different. i want to take one of the points that falls within the polygon and merge it attributes into one of the polygons.

Example of my polygons and points

It doesn't show it in the picture but there are 3 polygons stacked on top of each other. It doesn't matter what point goes to what polygon it just needs to be one point to one polygon.

EDIT: I was advised I did not provide enough detail on my overall goal. What I am trying to do is match my team's water meter layer up with another team's list of water meters. The issue is we do not have any form of ID to link it to their system (they have the master list of water meters). So what I was doing is using the Join by location tool with the water meters to get the parcel ID they sit in, and then use that parcel ID to do a merge in Excel against the other team's parcel ID. This worked for all parcels with 1 water meter per parcel but parcels with more then 1 water meter per parcel didn't work when using Join attributes by location.

EDIT: With Babel's help this is my code attempt. wserviceconnection is my point layer and Facility_I is the attribute I want to bring from the point layer to the polygon layer. When running this code it returns 'Facility_I' in the attribute field which is not what I expected as Facility_I contains numeric ID's e.g. 1234, 4321, 5678 etc

     overlay_intersects( 'wserviceconnection_1222df7a_de54_4063_ab09_4d911e6af8a3',  'Facility_I', limit:=10)
 [ array_find( 
     aggregate( 
        @layer,
        'array_agg',
        $id,
        filter:=intersects ($geometry, geometry(@parent))
        ),
        $id
)]

enter image description here

8
  • 1
    Are the polygons all 100% overlapping, and the points not overlapping? Also, is there always 1-1 points/polygons? Just trying to make sure what you have above is the entire question. Jun 5, 2023 at 4:43
  • Not sure what your workflow or task is and how what you intend really makes sense... Of course it's possible to do what you ask for, but depending on your final task, there might be better alternatives. Thus to me, it seems kind of an XY problem: meta.stackexchange.com/questions/66377/what-is-the-xy-problem
    – Babel
    Jun 5, 2023 at 8:32
  • @TomBrennan There is around 60k polygons so i can't check them all but i do believe they are 100% overlapping and the points are not overlapping. There is always 1 point per polygon.
    – Mow
    Jun 6, 2023 at 21:42
  • 1
    Field names should be in double quotes eg "Facility_I", not 'Facility_I' Jun 7, 2023 at 3:29
  • 1
    @Babel Running now as we speak. It has been running for over an hour but hasn't crashed yet. Will accept answer when it finishes.
    – Mow
    Jun 7, 2023 at 22:44

1 Answer 1

0

Let's say your point layer contains a field called name you want to join 1:1 to the same number of identical, overlapping polygons (duplicate geometries).

Use this expression on the polygon layer:

overlay_intersects ('point', name, limit:=10)  -- adapt the limit to the max. no of points that are within one polygon
[array_find (
    aggregate (
        @layer, 
        'array_agg',
        $id,
        filter:=intersects ($geometry, geometry(@parent))
    ),
    $id
)]

Screenshot: left, smaller polygon exists in 2 identical copies, larger right polygon in 3 identical copies: enter image description here

2
  • This didn't work for me. See original post for results.
    – Mow
    Jun 6, 2023 at 23:23
  • Seems you made it work now regarding the fact you accepted the answer?
    – Babel
    Jun 8, 2023 at 6:06

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.