Skip to content

Commit 8ff07cf

Browse files
Médéric RibreuxMédéric RIBREUX
authored andcommittedMay 29, 2016
Add i.landsat.acc algorithm
1 parent 90758b5 commit 8ff07cf

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed
 
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
i.landsat.acca
2+
Performs Landsat TM/ETM+ Automatic Cloud Cover Assessment (ACCA).
3+
Imagery (i.*)
4+
ParameterMultipleInput|rasters|Landsat input rasters|3|False
5+
ParameterNumber|b56composite|B56composite (step 6)|0|None|225|True
6+
ParameterNumber|b45ratio|B45ratio: Desert detection (step 10)|0|None|1|True
7+
ParameterNumber|histogram|Number of classes in the cloud temperature histogram|0|None|100|True
8+
*ParameterBoolean|-5|Data is Landsat-5 TM|False
9+
*ParameterBoolean|-f|Apply post-processing filter to remove small holes|False
10+
*ParameterBoolean|-x|Always use cloud signature (step 14)|False
11+
*ParameterBoolean|-2|Bypass second-pass processing, and merge warm (not ambiguous) and cold clouds|False
12+
*ParameterBoolean|-s|Include a category for cloud shadows|False
13+
OutputRaster|output|ACCA Raster
14+

‎python/plugins/processing/algs/grass7/ext/i.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,24 @@ def multipleOutputDir(alg, field, basename=None):
5151
alg.outputCommands.extend(commands)
5252

5353

54-
def orderedInput(alg, inputParameter, targetParameterDef):
54+
def orderedInput(alg, inputParameter, targetParameterDef, numSeq=None):
5555
"""Inport multiple rasters in the order"""
5656
rasters = alg.getParameterValue(inputParameter).split(';')
5757
# TODO: make targetParameter
5858
inputParameter = getParameterFromString(targetParameterDef)
5959
rootFilename = '{}_'.format(alg.getTempFilename())
6060
inputParameter.value = rootFilename
6161
alg.addParameter(inputParameter)
62+
# Handle specific range
63+
if numSeq is None:
64+
numSeq = range(1, len(rasters) + 1)
65+
6266
for idx in range(len(rasters)):
6367
layer = rasters[idx]
6468
if layer in alg.exportedLayers.keys():
6569
continue
6670
else:
67-
destFilename = '{}{}'.format(rootFilename, idx + 1)
71+
destFilename = '{}{}'.format(rootFilename, numSeq[idx])
6872
alg.setSessionProjectionFromLayer(layer, alg.commands)
6973
alg.exportedLayers[layer] = destFilename
7074
command = 'r.external input={} band=1 output={} --overwrite -o'.format(layer, destFilename)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
i_landsat_acca.py
6+
-----------------
7+
Date : March 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'March 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
from i import verifyRasterNum, orderedInput
29+
30+
31+
def checkParameterValuesBeforeExecuting(alg):
32+
return verifyRasterNum(alg, 'rasters', 5, 5)
33+
34+
35+
def processInputs(alg):
36+
orderedInput(alg, 'rasters',
37+
"ParameterString|input|Base name of input raster bands|None|False|False",
38+
[2, 3, 4, 5, 61])
39+
40+
41+
def processCommand(alg):
42+
# Remove rasters parameter
43+
rasters = alg.getParameterFromName('rasters')
44+
alg.parameters.remove(rasters)
45+
46+
alg.processCommand()
47+
48+
# re-add rasters
49+
alg.addParameter(rasters)

‎python/plugins/processing/algs/grass7/ext/i_landsat_toar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def checkParameterValuesBeforeExecuting(alg):
3535

3636
def processInputs(alg):
3737
orderedInput(alg, 'rasters',
38-
"ParameterString|input|Base name of input raster bands|None|False|False")
38+
"ParameterString|input|Base name of input raster bands|None|False|False",
39+
[1, 2, 3, 4, 5, 61, 62, 7, 8])
3940

4041

4142
def processCommand(alg):
@@ -52,7 +53,6 @@ def processCommand(alg):
5253
param.value = '{}_'.format(alg.getTempFilename())
5354
alg.addParameter(param)
5455

55-
# Regroup rasters
5656
alg.processCommand()
5757

5858
# re-add output

0 commit comments

Comments
 (0)
Please sign in to comment.