diff --git a/src/analysis/processing/qgsalgorithmzonalhistogram.cpp b/src/analysis/processing/qgsalgorithmzonalhistogram.cpp index 26203597ddf8..7d3ddcc04a76 100644 --- a/src/analysis/processing/qgsalgorithmzonalhistogram.cpp +++ b/src/analysis/processing/qgsalgorithmzonalhistogram.cpp @@ -68,7 +68,7 @@ QgsZonalHistogramAlgorithm *QgsZonalHistogramAlgorithm::createInstance() const return new QgsZonalHistogramAlgorithm(); } -bool QgsZonalHistogramAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback * ) +bool QgsZonalHistogramAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) { QgsRasterLayer *layer = parameterAsRasterLayer( parameters, QStringLiteral( "INPUT_RASTER" ), context ); if ( !layer ) @@ -84,6 +84,21 @@ bool QgsZonalHistogramAlgorithm::prepareAlgorithm( const QVariantMap ¶meters mCellSizeY = std::abs( layer->rasterUnitsPerPixelX() ); mNbCellsXProvider = mRasterInterface->xSize(); mNbCellsYProvider = mRasterInterface->ySize(); + Qgis::DataType dataType = mRasterInterface->dataType( mRasterBand ); + + switch ( dataType ) + { + case Qgis::DataType::Byte: + case Qgis::DataType::Int16: + case Qgis::DataType::UInt16: + case Qgis::DataType::Int32: + case Qgis::DataType::UInt32: + break; + default: + feedback->pushWarning( QObject::tr( "The input raster is a floating-point raster. Such rasters are not suitable for use with zonal histogram algorithm.\n" + "Please use Round raster or Reclassify by table tools to reduce number of decimal places or define histogram bins." ) ); + break; + } return true; }