<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">Hello,<br>
<br>
>From a processing script, I would like to compute raster statistics from a feature.geometry().<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">I call QgsZonalStatistics.calculateStatistics() with :<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">    QgsZonalStatistics.calculateStatistics(<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">        Raster.dataProvider(),<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">        Feature.geometry(),<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">        Raster.rasterUnitsPerPixelX(),
<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">        Raster.rasterUnitsPerPixelY(),<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">        1,<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">        QgsZonalStatistics.Statistic.All<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">    )<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">The output contain a dict :<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">    {0: 6.4578613687}<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">Which correspond to Variety (last value inserted in results here
<a href="https://qgis.org/api/qgszonalstatistics_8cpp_source.html">https://qgis.org/api/qgszonalstatistics_8cpp_source.html</a>)<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">Do you agree that the output should contain all statistics since I use QgsZonalStatistics.Statistic.All ?<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">Is this a bug or a feature ?<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">Another question :<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">How I am supposed to build the last argument of calculateStatistics() if I want to compute only Mean and Median ?<o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri, sans-serif">
<span lang="EN-US" style="color:#1F497D;mso-ansi-language:EN-US">Kind regards,<o:p> </o:p></span></p>
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Nicolas</div>
</body>
</html>