@@ -73,12 +73,14 @@ void QgsRasterAnalysisUtils::statisticsFromMiddlePointTest( QgsRasterInterface *
73
73
int iterTop = 0 ;
74
74
int iterCols = 0 ;
75
75
int iterRows = 0 ;
76
- while ( iter.readNextRasterPart ( rasterBand, iterCols, iterRows, block, iterLeft, iterTop ) )
76
+ QgsRectangle blockExtent;
77
+ while ( iter.readNextRasterPart ( rasterBand, iterCols, iterRows, block, iterLeft, iterTop, &blockExtent ) )
77
78
{
78
- double cellCenterY = rasterBBox.yMinimum () + ( iterTop + iterRows - 0.5 ) * cellSizeY;
79
+ double cellCenterY = blockExtent.yMaximum () - 0.5 * cellSizeY;
80
+
79
81
for ( int row = 0 ; row < iterRows; ++row )
80
82
{
81
- double cellCenterX = rasterBBox .xMinimum () + ( iterLeft + 0.5 ) * cellSizeX;
83
+ double cellCenterX = blockExtent .xMinimum () + 0.5 * cellSizeX;
82
84
for ( int col = 0 ; col < iterCols; ++col )
83
85
{
84
86
double pixelValue = block->value ( row, col );
@@ -121,12 +123,13 @@ void QgsRasterAnalysisUtils::statisticsFromPreciseIntersection( QgsRasterInterfa
121
123
int iterTop = 0 ;
122
124
int iterCols = 0 ;
123
125
int iterRows = 0 ;
124
- while ( iter.readNextRasterPart ( rasterBand, iterCols, iterRows, block, iterLeft, iterTop ) )
126
+ QgsRectangle blockExtent;
127
+ while ( iter.readNextRasterPart ( rasterBand, iterCols, iterRows, block, iterLeft, iterTop, &blockExtent ) )
125
128
{
126
- double currentY = rasterBBox. yMinimum () + ( iterTop + iterRows - 0.5 ) * cellSizeY;
129
+ double currentY = blockExtent. yMaximum () - 0.5 * cellSizeY;
127
130
for ( int row = 0 ; row < iterRows; ++row )
128
131
{
129
- double currentX = rasterBBox .xMinimum () + ( iterLeft + 0.5 ) * cellSizeX;
132
+ double currentX = blockExtent .xMinimum () + 0.5 * cellSizeX;
130
133
for ( int col = 0 ; col < iterCols; ++col )
131
134
{
132
135
double pixelValue = block->value ( row, col );
0 commit comments