How to fill gaps in SLC-Off Landsat 7 ETM+ Images with QGIS?


from qgis.core import QgsProcessing
from qgis.core import QgsProcessingAlgorithm
from qgis.core import QgsProcessingMultiStepFeedback
from qgis.core import QgsProcessingParameterRasterLayer
from qgis.core import QgsProcessingParameterNumber
from qgis.core import QgsProcessingParameterBoolean
from qgis.core import QgsProcessingParameterRasterDestination
import processing


class Gapfilllandsat7(QgsProcessingAlgorithm):

    def initAlgorithm(self, config=None):
        self.addParameter(QgsProcessingParameterRasterLayer('inputband', 'Input Band', defaultValue=None))
        self.addParameter(QgsProcessingParameterRasterLayer('inputmask', 'Input mask (define qué áreas se deben rellenar)', defaultValue=None))
        self.addParameter(QgsProcessingParameterNumber('searchdistanceelnmerodepxelesparabuscarentodaslasdireccionesparainterpolar', 'Search distance (El número de píxeles para buscar en todas las direcciones para interpolar)', type=QgsProcessingParameterNumber.Integer, minValue=10, maxValue=100, defaultValue=50))
        self.addParameter(QgsProcessingParameterBoolean('validitymask', 'Validity Mask', defaultValue=True))
        self.addParameter(QgsProcessingParameterRasterDestination('Output', 'Output', createByDefault=True, defaultValue=None))

    def processAlgorithm(self, parameters, context, model_feedback):
        # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the
        # overall progress through the model
        feedback = QgsProcessingMultiStepFeedback(1, model_feedback)
        results = {}
        outputs = {}

        # Fill nodata
        alg_params = {
            'BAND': 1,
            'DISTANCE': parameters['searchdistanceelnmerodepxelesparabuscarentodaslasdireccionesparainterpolar'],
            'INPUT': parameters['inputband'],
            'ITERATIONS': 0,
            'MASK_LAYER': parameters['inputmask'],
            'NO_MASK': parameters['validitymask'],
            'OUTPUT': parameters['Output']
        }
        outputs['FillNodata'] = processing.run('gdal:fillnodata', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
        results['Output'] = outputs['FillNodata']['OUTPUT']
        return results

    def name(self):
        return 'GAP-FILL-LANDSAT 7'

    def displayName(self):
        return 'GAP-FILL-LANDSAT 7'

    def group(self):
        return 'Processing'

    def groupId(self):
        return 'Processing'

    def createInstance(self):
        return Gapfilllandsat7()