2

I am looking at doing a spatial query where I can find when the center of one feature falls within another. Both geometries are on different layers. For example, when the center (centroid) of an area (source layer) falls within the polygon of another area (target layer). If the centroid of the source layer is within the target layer, the expression should then give out the specific attribute from the target layer.

Example: The orange layer is created by myself. Now I want to compute the centroid of that layer. The centroid would fall within the blue layer, here in the Polygon "BSAltona ...". Now in the blue layer polygon there is an attribute I want to extract (a link to a website). enter image description here

Right now I am using Reffunction (geomwithin and geomverlaps) however there are to many situations, in which the the orange layer would be intersecting multiple of the blue layers (see Picture 2). In this case none of the reffunctions gives out the fitting attribute.

Right now I am using the following:

[%if(geomwithin('layer', 'attribute') is not NULL, geomwithin('layer', 'attribute'), geomoverlaps('layer', 'attribute'))%]

In this situation it would be most logical in my case to give out only the information of the blue layer that intersects with the centroid of the orange layer. However is think this is not possible with reffunctions.

enter image description here

Also, I am looking to this as an expression only, as I want to insert this into the atlas function. This is why creating a separate layer using the normal create centroid function would hinder my workflow too much.

1
  • 2
    I suggest you add you current function for retrieving the attribute of interest.
    – Erik
    Commented Nov 11, 2020 at 10:38

1 Answer 1

0

I solved this using the aggregate function:

Returns an aggregate value calculated using features from another layer

[%aggregate('Bluelayer','concatenate',"attribute", intersects($geometry,centroid(@atlas_geometry)), ',')%]

attriube = link to pdf file / website

the atlas geometry represents the orange polygon.

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.