<div dir="ltr" gmail_original="1"><div>You can use expressions to achieve this. I cover a similar problem of conditional spatial join with an example in this video <a href="https://l.shortlink.es/l/e53315961a63187508c99a5f2604e5ddbcf65c6f?w=cWdpcy11c2VyQGxpc3RzLm9zZ2VvLm9yZw&u=8747767">https://www.youtube.com/watch?v=qpiFT8UHhwM</a></div><div><br></div><div>In your case, you can use the aggregate() expression with an additional filter to select features where the attributes of both layers match. If the common attribute name is 'direction', add a condition in the filter like "direction" = attribute(@parent, 'direction') and specify the required statistic like 'mean', 'count' etc. as the aggregate.</div><div><div dir="ltr" class="gmail_signature"><div dir="ltr">---<div>Ujaval Gandhi</div><div>Spatial Thoughts</div><div><a href="https://l.shortlink.es/l/6911ea9a77e1c0ab611c66a0690a6d0ffc2b8ffd?w=cWdpcy11c2VyQGxpc3RzLm9zZ2VvLm9yZw&u=8747767" target="_blank">www.spatialthoughts.com</a></div><div><br></div></div></div></div><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Jul 10, 2025 at 1:01 PM Roland Spielhofer via QGIS-User <qgis-user@lists.osgeo.org> wrote:<br></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">Hi Chris,</span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">thanks for your suggestions!</span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);"> </span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">The data is in Shapefiles, I do not have a PostGIS installation at hand...</div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"> </div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">What you mention is indeed what I am looking for - some statistical parameters (mean, count, min, max) of the points that fall into a polygon counting only the points that have the same direction attribute as the polygon.</div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">I will try with virtual layers.</div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"> </div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">Regards,</div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">Roland</div>
<div id="m_5329002951829819391sub-body-container" style="margin: 10px 5px 5px 10px; padding: 10px 0px 10px 10px; border-left: 2px solid rgb(195, 217, 229);">
<div style="margin: 0px 0px 10px;">
<div><strong>Gesendet: </strong>Mittwoch, 9. Juli 2025 um 15:28</div>
<div><strong>Von: </strong>"chris hermansen" <<a href="mailto:clhermansen@gmail.com" target="_blank">clhermansen@gmail.com</a>></div>
<div><strong>An: </strong>"Roland Spielhofer" <<a href="mailto:rspiel@gmx.net" target="_blank">rspiel@gmx.net</a>></div>
<div><strong>CC: </strong>qgis-user <<a href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a>></div>
<div><strong>Betreff: </strong>Re: [Qgis-user] Join attributes by location (summary) with condition</div>
</div>
<div>Roland and liat<br><br>
<img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/w/cWdpcy11c2VyQGxpc3RzLm9zZ2VvLm9yZw/de5d47d312e2b86384ce137940b3839c96ac99a2.png?u=8747767" ><div class="gmail_quote">
<div class="gmail_attr">On Wed, Jul 9, 2025, 01:33 Roland Spielhofer via QGIS-User <<a href="mailto:qgis-user@lists.osgeo.org" rel="noopener noreferrer" target="_blank">qgis-user@lists.osgeo.org</a>> wrote:</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">Hi,</span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">I am trying to get mean values from points lying inside polygons - that would be easy with "join attributes by location (summary)".</span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);"> </span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">But: I have overlapping polygons - coming from road segments (motorways with separate lines per direction). The points and the polygons have a common attribute ("+" or "-" per direction) .</span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);"> </span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">I want to summarize the points of one direction that are lying inside the polygon of the same direction.</span></div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"> </div>
<div style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);">Is there a way to achieve this?</span></div>
</blockquote>
</div>
<div> </div>
<div>Are you able to use SQL?</div>
<div> </div>
<div>This is a straightforward query in (for example) PostGIS, which offers spatial comparison operations such as "within"</div>
<div> </div>
<div><a href="https://postgis.net/docs/ST_Within.html" rel="noopener noreferrer" target="_blank">https://postgis.net/docs/ST_<wbr>Within.html</a></div>
<div> </div>
<div>So if you select polygons and join the points using ST_within you can (for example) use GROUP BY and (for example) AVERAGE to get the average value of some attribute for all points within each polygon.</div>
<div> </div>
<div>Is this the kind of thing you are looking for?</div>
<div class="gmail_quote"> </div>
</div>
</div>
______________________________<wbr>_________________<br>
QGIS-User mailing list<br>
<a href="mailto:QGIS-User@lists.osgeo.org" target="_blank">QGIS-User@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
</blockquote></div>