Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Médéric RIBREUX
committed
Feb 28, 2016
1 parent
960f3a9
commit 3a9846b
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
python/plugins/processing/algs/grass7/description/r.stats.quantile.out.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
r.stats.quantile | ||
r.stats.quantile.out - Compute category quantiles using two passes and output statistics | ||
Raster (r.*) | ||
ParameterRaster|base|Name of base raster map|False | ||
ParameterRaster|cover|Name of cover raster map|False | ||
ParameterString|quantiles|Number of quantiles|None|False|True | ||
ParameterString|percentiles|List of percentiles|None|False|True | ||
ParameterNumber|bins|Number of bins to use|0|None|1000|True | ||
*ParameterBoolean|-r|Create reclass map with statistics as category labels|False | ||
Hardcoded|-p | ||
OutputFile|output|Statistics File | ||
|
11 changes: 11 additions & 0 deletions
11
python/plugins/processing/algs/grass7/description/r.stats.quantile.rast.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
r.stats.quantile | ||
r.stats.quantile.rast - Compute category quantiles using two passes and output rasters. | ||
Raster (r.*) | ||
ParameterRaster|base|Name of base raster map|False | ||
ParameterRaster|cover|Name of cover raster map|False | ||
ParameterNumber|quantiles|Number of quantiles|2|None|2|True | ||
ParameterString|percentiles|List of percentiles|None|False|True | ||
ParameterNumber|bins|Number of bins to use|0|None|1000|True | ||
*ParameterBoolean|-r|Create reclass map with statistics as category labels|False | ||
OutputDirectory|output_dir|Output Directory | ||
|
66 changes: 66 additions & 0 deletions
66
python/plugins/processing/algs/grass7/ext/r_stats_quantile_rast.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
r_stats_quantile_rast.py | ||
------------------------ | ||
Date : February 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__ = 'February 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 processing.core.parameters import getParameterFromString | ||
import os | ||
|
||
|
||
def processCommand(alg): | ||
# We create the output sequence according to percentiles number | ||
base = alg.getParameterValue('base') | ||
quantiles = alg.getParameterValue('quantiles') - 1 | ||
outputs = [] | ||
for i in range(0, int(quantiles)): | ||
outputs.append('output_{}'.format(i)) | ||
|
||
output = getParameterFromString('ParameterString|output|Output Rasters|None|False|True') | ||
output.value = ','.join(outputs) | ||
alg.addParameter(output) | ||
|
||
output_dir = alg.getOutputFromName('output_dir') | ||
alg.removeOutputFromName('output_dir') | ||
|
||
# Launch the algorithm | ||
alg.processCommand() | ||
|
||
# We re-add the previous output | ||
alg.addOutput(output_dir) | ||
|
||
|
||
def processOutputs(alg): | ||
# We need to export each of the output | ||
output_dir = alg.getOutputValue('output_dir') | ||
outputParam = alg.getParameterFromName('output') | ||
outputs = outputParam.value.split(',') | ||
alg.parameters.remove(outputParam) | ||
for output in outputs: | ||
command = u"r.out.gdal -c createopt=\"TFW=YES,COMPRESS=LZW\" input={} output=\"{}\" --overwrite".format( | ||
output, | ||
os.path.join(output_dir, output + '.tif') | ||
) | ||
alg.commands.append(command) | ||
alg.outputCommands.append(command) |