[QGIS-Developer] Expressions with aggregate in PyQGIS
Anita Graser
anitagraser at gmx.at
Sat May 25 06:44:14 PDT 2019
Hi,
I've started a PR with the aggregate expression example here:
https://github.com/qgis/QGIS-Documentation/pull/3769
Regards,
Anita
On Tue, May 21, 2019 at 12:15 AM Nyall Dawson <nyall.dawson at gmail.com>
wrote:
> On Tue, 21 May 2019 at 05:53, Anita Graser <anitagraser at gmx.at> wrote:
> >
> > Dear Nyall,
> >
> > for f in vl.getFeatures():
> > scope[-1].setFeature(f)
>
> This works, but isn't very nice. Better to use
>
> context.setFeature(f)
>
> (behind the scenes it's doing the same, but is more descriptive and
> has some extra checks, e.g. starting with an empty context:
> context = QgsExpressionContext()
> context.setFeature(f)
> will automatically add an initial scope in which to set the feature)
>
> > scope = QgsExpressionContextUtils.globalProjectLayerScopes(vl)
>
> Being pedantic, this should be "scopes = ...", since the call returns
> a list of scopes.
>
> Nyall
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190525/28b74c01/attachment-0001.html>
More information about the QGIS-Developer
mailing list