Hi,
I have a basic example using aggregates:
----------------------
@qgsfunction(args='auto', group='Custom', usesgeometry=False)
def get_ews_anlage_nr(gemeinde, feature, parent):
AnlageLayer =
QgsMapLayerRegistry.instance().mapLayersByName('Anlage')[0]
maxVal = AnlageLayer.aggregate(4,'to_int(substr("anlage_nr",4,4))')[0]
return maxVal
-----------------------
But I still have two questions:
1. I still struggle to define a filter. I can't find the correct syntax
how to define that filter string.
2. the first parameter "4" stands for "Max" aggregate (according to
http://qgis-python.kartoza.com/docs/core/other/QgsAggregateCalculator.html#class-qgsaggregatecalculator
). Could this code be written more "readable" by specifying "Max"
instead of 4?
Thanks,
Andreas
On 2017-05-05 14:31, Neumann, Andreas wrote:
> Hi,
>
> Does someone have an example how to use QgsVectorLayer.aggregate() from
> Python?
>
> How would the syntax for the parameters in the
> QgsAggregateCalculator.calculate() method look like in Python?
>
> Thanks,
>
> Andreas
>
> _______________________________________________
> QGIS-Developer mailing list
> [email protected]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer