[QGIS-Developer] QgsZonalStatistics.calculateStatistics() missing outputs

Nicolas Godet nicolas.godet at outlook.fr
Fri May 7 00:24:48 PDT 2021


Hello,

>From a processing script, I would like to compute raster statistics from a feature.geometry().
I call QgsZonalStatistics.calculateStatistics() with :
    QgsZonalStatistics.calculateStatistics(
        Raster.dataProvider(),
        Feature.geometry(),
        Raster.rasterUnitsPerPixelX(),
        Raster.rasterUnitsPerPixelY(),
        1,
        QgsZonalStatistics.Statistic.All
    )

The output contain a dict :
    {0: 6.4578613687}
Which correspond to Variety (last value inserted in results here https://qgis.org/api/qgszonalstatistics_8cpp_source.html)
Do you agree that the output should contain all statistics since I use QgsZonalStatistics.Statistic.All ?
Is this a bug or a feature ?

Another question :
How I am supposed to build the last argument of calculateStatistics() if I want to compute only Mean and Median ?

Kind regards,

Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210507/bff36337/attachment.html>


More information about the QGIS-Developer mailing list