Skip to content

Commit

Permalink
Add i.landsat.acc algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric Ribreux authored and Médéric RIBREUX committed May 29, 2016
1 parent 90758b5 commit 8ff07cf
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
@@ -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

8 changes: 6 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i.py
Expand Up @@ -51,20 +51,24 @@ 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
inputParameter = getParameterFromString(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)
Expand Down
49 changes: 49 additions & 0 deletions 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)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_landsat_toar.py
Expand Up @@ -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):
Expand All @@ -52,7 +53,6 @@ def processCommand(alg):
param.value = '{}_'.format(alg.getTempFilename())
alg.addParameter(param)

# Regroup rasters
alg.processCommand()

# re-add output
Expand Down

0 comments on commit 8ff07cf

Please sign in to comment.