[Qgis-user] Using aggregates functions to count intersected features from another layer

DelazJ delazj at gmail.com
Thu Oct 27 08:45:17 PDT 2016


Thanks to you and for the ongoing work!

2016-10-20 8:14 GMT+02:00 Matthias Kuhn <matthias at opengis.ch>:

> On 10/20/2016 12:33 AM, Nyall Dawson wrote:
> > On 19 October 2016 at 22:22, Neumann, Andreas <a.neumann at carto.net>
> wrote:
> > - attributes from the parent feature are automatically available
> > within the filter, UNLESS there's a duplicate field name from the
> > child feature
>
> I like this, e.g. PostgreSQL handles it the same way for joined fields.
> But it warns in case of duplication and requires an explicit source
> table statement in case of duplication. In the case where the child
> feature suddenly gets a new field with the same name, the semantic of
> the expression should not silently change but a warning be issued.
>
> > - expose the parent feature via the variable @parent. This could be
> > used with the functions geometry(@parent), attribute(@parent,
> > "some_dup_field_name")
>
> Based on above statement, there should also be a @child variable.
> Or attributes could be exposed as parent.attr / child.attr.
>
> >
> > Then you'd be able to write:
> >
> > aggregate ('mypoint', 'count', "id", intersects ($geometry,
> geometry(@parent)))
>
> aggregate('mypoint', 'count', "id", mypoint.fk = @parent.id))
>
> or
>
> aggregate('mypoint', 'count', "id", attribute(@child, "id") =
> attribute(@parent, "id"))
>
> # Error in case both have a field "id"
> aggregate('mypoint', 'count', "id", mypoint.fk = "id"))
>
> >
> > The trickiest part in implementing this would be making sure the
> > current aggregate value cache correctly handles use of parent feature
> > attributes/geometry.
> >
> > Re virtual layers: I've always seen these as a "heavier" (+ more
> > powerful!) approach, which is OK for some use cases but for others (Eg
> > data defined controls, composer labels, etc) it's preferable to have
> > these calculations available directly within the expression engine.
>
> I also think this needs to be fixed in expressions. I have a use-case
> for it with default values at the moment.
>
> Matthias
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20161027/f4c04a57/attachment.html>


More information about the Qgis-user mailing list