diff --git a/python/plugins/processing/algs/grass7/description/i.landsat.acca.txt b/python/plugins/processing/algs/grass7/description/i.landsat.acca.txt new file mode 100644 index 00000000000..4b7e8f23bdb --- /dev/null +++ b/python/plugins/processing/algs/grass7/description/i.landsat.acca.txt @@ -0,0 +1,14 @@ +i.landsat.acca +Performs Landsat TM/ETM+ Automatic Cloud Cover Assessment (ACCA). +Imagery (i.*) +ParameterMultipleInput|rasters|Landsat input rasters|3|False +ParameterNumber|b56composite|B56composite (step 6)|0|None|225|True +ParameterNumber|b45ratio|B45ratio: Desert detection (step 10)|0|None|1|True +ParameterNumber|histogram|Number of classes in the cloud temperature histogram|0|None|100|True +*ParameterBoolean|-5|Data is Landsat-5 TM|False +*ParameterBoolean|-f|Apply post-processing filter to remove small holes|False +*ParameterBoolean|-x|Always use cloud signature (step 14)|False +*ParameterBoolean|-2|Bypass second-pass processing, and merge warm (not ambiguous) and cold clouds|False +*ParameterBoolean|-s|Include a category for cloud shadows|False +OutputRaster|output|ACCA Raster + diff --git a/python/plugins/processing/algs/grass7/ext/i.py b/python/plugins/processing/algs/grass7/ext/i.py index 3a7bb6f2be8..3b58250e8f7 100644 --- a/python/plugins/processing/algs/grass7/ext/i.py +++ b/python/plugins/processing/algs/grass7/ext/i.py @@ -51,7 +51,7 @@ def multipleOutputDir(alg, field, basename=None): alg.outputCommands.extend(commands) -def orderedInput(alg, inputParameter, targetParameterDef): +def orderedInput(alg, inputParameter, targetParameterDef, numSeq=None): """Inport multiple rasters in the order""" rasters = alg.getParameterValue(inputParameter).split(';') # TODO: make targetParameter @@ -59,12 +59,16 @@ def orderedInput(alg, inputParameter, targetParameterDef): rootFilename = '{}_'.format(alg.getTempFilename()) inputParameter.value = rootFilename alg.addParameter(inputParameter) + # Handle specific range + if numSeq is None: + numSeq = range(1, len(rasters) + 1) + for idx in range(len(rasters)): layer = rasters[idx] if layer in alg.exportedLayers.keys(): continue else: - destFilename = '{}{}'.format(rootFilename, idx + 1) + destFilename = '{}{}'.format(rootFilename, numSeq[idx]) alg.setSessionProjectionFromLayer(layer, alg.commands) alg.exportedLayers[layer] = destFilename command = 'r.external input={} band=1 output={} --overwrite -o'.format(layer, destFilename) diff --git a/python/plugins/processing/algs/grass7/ext/i_landsat_acca.py b/python/plugins/processing/algs/grass7/ext/i_landsat_acca.py new file mode 100644 index 00000000000..cef94b077a0 --- /dev/null +++ b/python/plugins/processing/algs/grass7/ext/i_landsat_acca.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + i_landsat_acca.py + ----------------- + Date : March 2016 + Copyright : (C) 2016 by Médéric Ribreux + Email : medspx at medspx dot fr +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" + +__author__ = 'Médéric Ribreux' +__date__ = 'March 2016' +__copyright__ = '(C) 2016, Médéric Ribreux' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +from i import verifyRasterNum, orderedInput + + +def checkParameterValuesBeforeExecuting(alg): + return verifyRasterNum(alg, 'rasters', 5, 5) + + +def processInputs(alg): + orderedInput(alg, 'rasters', + "ParameterString|input|Base name of input raster bands|None|False|False", + [2, 3, 4, 5, 61]) + + +def processCommand(alg): + # Remove rasters parameter + rasters = alg.getParameterFromName('rasters') + alg.parameters.remove(rasters) + + alg.processCommand() + + # re-add rasters + alg.addParameter(rasters) diff --git a/python/plugins/processing/algs/grass7/ext/i_landsat_toar.py b/python/plugins/processing/algs/grass7/ext/i_landsat_toar.py index d084ebde5a5..4e360cd7e52 100644 --- a/python/plugins/processing/algs/grass7/ext/i_landsat_toar.py +++ b/python/plugins/processing/algs/grass7/ext/i_landsat_toar.py @@ -35,7 +35,8 @@ def checkParameterValuesBeforeExecuting(alg): def processInputs(alg): orderedInput(alg, 'rasters', - "ParameterString|input|Base name of input raster bands|None|False|False") + "ParameterString|input|Base name of input raster bands|None|False|False", + [1, 2, 3, 4, 5, 61, 62, 7, 8]) def processCommand(alg): @@ -52,7 +53,6 @@ def processCommand(alg): param.value = '{}_'.format(alg.getTempFilename()) alg.addParameter(param) - # Regroup rasters alg.processCommand() # re-add output