mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-10 00:08:20 -05:00
parent
a50304789e
commit
13a43de935
@ -277,7 +277,7 @@ QVariantMap QgsCellStatisticsAlgorithm::processAlgorithm( const QVariantMap &par
|
|||||||
outputBlock->setValue( row, col, mNoDataValue );
|
outputBlock->setValue( row, col, mNoDataValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !noDataInStack || mIgnoreNoData )
|
else if ( !noDataInStack || ( mIgnoreNoData && cellValueStackSize > 0 ) )
|
||||||
{
|
{
|
||||||
switch ( method )
|
switch ( method )
|
||||||
{
|
{
|
||||||
@ -320,6 +320,11 @@ QVariantMap QgsCellStatisticsAlgorithm::processAlgorithm( const QVariantMap &par
|
|||||||
}
|
}
|
||||||
outputBlock->setValue( row, col, result );
|
outputBlock->setValue( row, col, result );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//result is NoData if cellValueStack contains no valid values, eg. all cellValues are NoData
|
||||||
|
outputBlock->setValue( row, col, mNoDataValue );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
provider->writeBlock( outputBlock.get(), 1, iterLeft, iterTop );
|
provider->writeBlock( outputBlock.get(), 1, iterLeft, iterTop );
|
||||||
|
|||||||
@ -2360,6 +2360,17 @@ void TestQgsProcessingAlgs::cellStatistics_data()
|
|||||||
<< QStringLiteral( "/cellstatistics_median_result_fourLayers_float32.tif" )
|
<< QStringLiteral( "/cellstatistics_median_result_fourLayers_float32.tif" )
|
||||||
<< Qgis::Float32;
|
<< Qgis::Float32;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Testcase 19: sum with raster cell stacks containing only nodata
|
||||||
|
*/
|
||||||
|
QTest::newRow( "testcase_19" )
|
||||||
|
<< QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas1_float64.asc"} )
|
||||||
|
<< QStringLiteral( "/raster/statisticsRas3_int32.tif" )
|
||||||
|
<< 0
|
||||||
|
<< true
|
||||||
|
<< QStringLiteral( "/cellstatistics_sum_result_ignoreNoData.tif" )
|
||||||
|
<< Qgis::Float64;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsProcessingAlgs::cellStatistics()
|
void TestQgsProcessingAlgs::cellStatistics()
|
||||||
|
|||||||
BIN
tests/testdata/control_images/expected_cellStatistics/cellstatistics_sum_result_ignoreNoData.tif
vendored
Normal file
BIN
tests/testdata/control_images/expected_cellStatistics/cellstatistics_sum_result_ignoreNoData.tif
vendored
Normal file
Binary file not shown.
10
tests/testdata/raster/statisticsRas4_float64.asc
vendored
Normal file
10
tests/testdata/raster/statisticsRas4_float64.asc
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
ncols 4
|
||||||
|
nrows 4
|
||||||
|
xllcorner 0
|
||||||
|
yllcorner 0
|
||||||
|
cellsize 1
|
||||||
|
nodata_value -9999.0
|
||||||
|
1.0 1.0 0.0 0.0
|
||||||
|
-9999.0 1.0 2.0 2.0
|
||||||
|
4.0 0.0 0.0 2.0
|
||||||
|
4.0 0.0 1.0 1.0
|
||||||
Loading…
x
Reference in New Issue
Block a user