Geographic Information Systems Asked on February 17, 2021
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).
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.
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.
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.
Correct answer by Corninski on February 17, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP