<div dir="ltr">Maybe using a virtual layer query via DB Manager will work. You have full SQL join support. Speed isn't always the best but gives you the full power of SQL which is the correct way to do this IMO.<div><br></div><div>E.g SELECT LayerA.id, COUNT(*) FROM layerA </div><div>JOIN layerB ON ST_WithIn(layerA.geometry, layerB.geometry)</div><div>GROUP BY layerA.type</div><div><br></div><div>Although you can't do an update but you can make a new layer with the new counts.<br><div><br></div><div>- Nathan</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 19, 2016 at 10:22 PM, Neumann, Andreas <span dir="ltr"><<a href="mailto:a.neumann@carto.net" target="_blank">a.neumann@carto.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-size:10pt;font-family:Verdana,Geneva,sans-serif">
<p>Well yes - but that is not a "live" point in polygon. It create separate layers which need to be kept up-to-date.</p>
<p>Harrissou was after a "live" point in polygon, which is automatically kept up-to-date through a QGIS expression.</p>
<p>Maybe Nyall knows how to write the correct aggregate expression for that?</p>
<p>Greetings,</p>
<p>Andreas</p><div><div class="h5">
<p>On 2016-10-19 14:11, Nicolas Cadieux wrote:</p>
</div></div><blockquote type="cite" style="padding:0 0.4em;border-left:#1010ff 2px solid;margin:0"><div><div class="h5">
<div> </div>
<div>Try this.</div>
<div> </div>
<div><a href="http://www.qgistutorials.com/fr/docs/points_in_polygon.html" target="_blank">http://www.qgistutorials.com/<wbr>fr/docs/points_in_polygon.html</a></div>
<div> </div>
<div>Nicolas</div>
<div><br>Le 19 oct. 2016 à 06:37, DelazJ [via <a href="http://OSGeo.org" target="_blank">OSGeo.org</a>] <<a>[hidden email]</a>> a écrit :<br><br></div>
<blockquote style="border-left:2px solid #cccccc;padding:0 1em">
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Hi,<br><br></div>
I have a polygon layer and a point one.</div>
I'd like to calculate for each polygon feature, the number of points that it covers. I thought the aggregates functions could help me find an easier and straight expression to perform this (without creating intermediate layers) but I fail to find any correct syntax. <br><br></div>
I tried aggregate ('mypoint', 'count', "id", intersects ($geometry, geometry($currentfeature)))<br><br> And many variants of the fourth option but It always return the total of points or an error. Actually this option is a filter and I wonder if i'm not missing a "group by" option in the aggregate function (which seems to be the appropriate one in my case). Is it possible?</div>
</div>
<div>The work around I found is to populate an ad'hoc field in the point layer with overlapping polygon id, thanks to the SpatialJoin plugin, then I create a one-to-many relation in the project between the two layers in other to use relation_aggregate function.</div>
<div>But I expected something more direct.</div>
<div><br>Any hint, please?<br><br></div>
Thanks,</div>
Harrissou</div>
<br>______________________________<wbr>_________________ <br>Qgis-user mailing list <br><a>[hidden email]</a> <br>List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a> <br><br><hr size="1">
<div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
<div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
<a href="http://osgeo-org.1560.x6.nabble.com/Using-aggregates-functions-to-count-intersected-features-from-another-layer-tp5291420.html" target="_blank">http://osgeo-org.1560.x6.<wbr>nabble.com/Using-aggregates-<wbr>functions-to-count-<wbr>intersected-features-from-<wbr>another-layer-tp5291420.html</a></div>
<div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">To start a new topic under Quantum GIS - User, email <a>[hidden email]</a> <br> To unsubscribe from Quantum GIS - User, <a>click here</a>.<br><a style="font:9px serif" href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" target="_blank">NAML</a></div>
</div>
</blockquote>
<br><hr align="left" width="300">View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Using-aggregates-functions-to-count-intersected-features-from-another-layer-tp5291420p5291443.html" target="_blank">Re: Using aggregates functions to count intersected features from another layer</a><br> Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/Quantum-GIS-User-f4125267.html" target="_blank">Quantum GIS - User mailing list archive</a> at Nabble.com.<br><br>
</div></div><div class="m_-8854446165931069833pre" style="margin:0;padding:0;font-family:monospace">______________________________<wbr>_________________<br> Qgis-user mailing list<br><a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><span class=""><br> List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br> Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a></span></div>
</blockquote>
<p> </p>
<div> </div>
</div>
<br>______________________________<wbr>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br></blockquote></div><br></div>