@@ -328,12 +328,12 @@ int QgsZonalStatistics::calculateStatistics( QgsFeedback *feedback )
328
328
std::sort ( vals.begin (), vals.end () );
329
329
if ( mStatistics & QgsZonalStatistics::Minority )
330
330
{
331
- float minorityKey = featureStats.valueCount .key ( vals.first () );
331
+ double minorityKey = featureStats.valueCount .key ( vals.first () );
332
332
changeAttributeMap.insert ( minorityIndex, QVariant ( minorityKey ) );
333
333
}
334
334
if ( mStatistics & QgsZonalStatistics::Majority )
335
335
{
336
- float majKey = featureStats.valueCount .key ( vals.last () );
336
+ double majKey = featureStats.valueCount .key ( vals.last () );
337
337
changeAttributeMap.insert ( majorityIndex, QVariant ( majKey ) );
338
338
}
339
339
}
@@ -422,15 +422,16 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly,
422
422
cellCenterX = rasterBBox.xMinimum () + pixelOffsetX * cellSizeX + cellSizeX / 2 ;
423
423
for ( int j = 0 ; j < nCellsX; ++j )
424
424
{
425
- if ( validPixel ( block->value ( i, j ) ) )
425
+ double pixelValue = block->value ( i, j );
426
+ if ( validPixel ( pixelValue ) )
426
427
{
427
428
cellCenterCoords = GEOSCoordSeq_create_r ( geosctxt, 1 , 2 );
428
429
GEOSCoordSeq_setX_r ( geosctxt, cellCenterCoords, 0 , cellCenterX );
429
430
GEOSCoordSeq_setY_r ( geosctxt, cellCenterCoords, 0 , cellCenterY );
430
431
currentCellCenter.reset ( GEOSGeom_createPoint_r ( geosctxt, cellCenterCoords ) );
431
432
if ( GEOSPreparedContains_r ( geosctxt, polyGeosPrepared.get (), currentCellCenter.get () ) )
432
433
{
433
- stats.addValue ( block-> value ( i, j ) );
434
+ stats.addValue ( pixelValue );
434
435
}
435
436
}
436
437
cellCenterX += cellSizeX;
@@ -461,7 +462,8 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry &p
461
462
double currentX = rasterBBox.xMinimum () + cellSizeX / 2.0 + pixelOffsetX * cellSizeX;
462
463
for ( int j = 0 ; j < nCellsX; ++j )
463
464
{
464
- if ( !validPixel ( block->value ( i, j ) ) )
465
+ double pixelValue = block->value ( i, j );
466
+ if ( !validPixel ( pixelValue ) )
465
467
{
466
468
continue ;
467
469
}
@@ -477,7 +479,7 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry &p
477
479
if ( intersectionArea >= 0.0 )
478
480
{
479
481
weight = intersectionArea / pixelArea;
480
- stats.addValue ( block-> value ( i, j ) , weight );
482
+ stats.addValue ( pixelValue , weight );
481
483
}
482
484
}
483
485
pixelRectGeometry = QgsGeometry ();
0 commit comments