Zonal Statistics do not always consider correct area fraction #52223
Labels
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
Processing
Relating to QGIS Processing framework or individual Processing algorithms
What is the bug or the crash?
When using the "Zonal statistics" algorithm it is not secured, that the complete area of the underlying raster layer, covered by the input vector layer, is incorporated in the calculation.
If there are polygons which do not cover more than one centroid of raster cells, the calculation will be processed as expected, regarding the pure fractions of the raster layer. (This behaviour ist considered as correct. Polygon 1, 2 and 5 in the test data and picture.)
But for polygons, covering more than one raster cell centroid, these complete cells are taken into consideration, even if they are not completely covered by the polygon (Polygon 3 and 4).
This mixture of handling raster cells in one algorithm is not only confusing. It also leads to wrong results.
The same issue was already mentioned here: #38273
(test data with included project here: data.zip)
Steps to reproduce the issue
(You can do a validation with an intersect and simple arithmetic operations. The result of this is also included in the test data and shown in the picture as the "aggregated" layer.)
Versions
<style type="text/css"> p, li { white-space: pre-wrap; } </style>Active Python plugins
qfieldsync
v4.2.0
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.6
processing
2.12.99
sagaprovider
2.12.99
Supported QGIS version
New profile
Additional context
Tests done with 3.22.16, 3.28.3, 3.28.4 on Windows, and also with 3.22.4 on an Ubuntu machine. Always the behaviour occourred which is described above.
The text was updated successfully, but these errors were encountered: