Skip to content

Commit a231bbd

Browse files
author
Médéric RIBREUX
committed
Add i.gensig algorithm
1 parent b533000 commit a231bbd

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
i.gensig
2+
Generates statistics for i.maxlik from raster map.
3+
Imagery (i.*)
4+
ParameterRaster|trainingmap|Ground truth training map|False
5+
ParameterMultipleInput|input|Input rasters|3|False
6+
OutputFile|signaturefile|Signature File
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
i_gensig.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 regroupRasters, file2Output, moveFile
29+
from os import path
30+
from ..Grass7Utils import Grass7Utils
31+
32+
33+
def processCommand(alg):
34+
# Transform output files in string parameter
35+
signatureFile = alg.getOutputFromName('signaturefile')
36+
origSigFile = signatureFile.value
37+
shortSigFile = path.basename(origSigFile)
38+
alg.setOutputValue('signaturefile', shortSigFile)
39+
40+
signatureFile = file2Output(alg, 'signaturefile')
41+
42+
# Regroup rasters
43+
group, subgroup = regroupRasters(alg, 'input', 'group', 'subgroup')
44+
45+
# Re-add signature files
46+
alg.addOutput(signatureFile)
47+
48+
# Find Grass directory
49+
interSig = path.join(Grass7Utils.grassMapsetFolder(), 'PERMANENT', 'group', group, 'subgroup', subgroup, 'sig', shortSigFile)
50+
moveFile(alg, interSig, origSigFile)
51+
alg.setOutputValue('signaturefile', origSigFile)

0 commit comments

Comments
 (0)