From 0b1a67bdbf9259975a0111f4b3f3d4d3e88afd3d Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Mon, 2 Mar 2015 19:27:02 +0200 Subject: [PATCH] [processing] TauDEM provider overhaul - add new TauDEM 5.1.2/5.2 tools: Gage watershed, TWI and Select GT Threshold - implement support for multifile TauDEM version - allow to use single- and multifile versions simultaneously Work done for Faunalia (http://faunalia.eu) (cherry-picked from 427adf79bb975fd436e69d2120d1261081eb4687) --- .../processing/algs/taudem/CMakeLists.txt | 6 +- .../processing/algs/taudem/TauDEMAlgorithm.py | 5 +- .../algs/taudem/TauDEMAlgorithmProvider.py | 113 +++++++++++----- .../algs/taudem/TauDEMMultifileAlgorithm.py | 122 +++++++++++++++++ .../processing/algs/taudem/TauDEMUtils.py | 28 +++- .../algs/taudem/description/multi/aread8.txt | 8 ++ .../taudem/description/multi/areadinf.txt | 8 ++ .../taudem/description/multi/d8flowdir.txt | 6 + .../description/multi/d8flowpathextremeup.txt | 9 ++ .../description/multi/d8hdisttostrm.txt | 7 + .../description/multi/dinfavalanche.txt | 11 ++ .../description/multi/dinfconclimaccum.txt | 11 ++ .../description/multi/dinfdecayaccum.txt | 9 ++ .../taudem/description/multi/dinfflowdir.txt | 6 + .../taudem/description/multi/dinfrevaccum.txt | 7 + .../description/multi/dinfupdependence.txt | 6 + .../description/multi/gagewatershed.txt | 6 + .../description/multi/gagewatershed2.txt | 7 + .../description/multi/moveoutletstostrm.txt | 8 ++ .../taudem/description/multi/pitremove.txt | 5 + .../description/multi/selectgtthreshold.txt | 6 + .../description/multi/slopearearatio.txt | 6 + .../taudem/description/multi/slopeavedown.txt | 7 + .../taudem/description/multi/streamnet.txt | 14 ++ .../taudem/description/multi/threshold.txt | 7 + .../algs/taudem/description/multi/twi.txt | 6 + .../description/{ => single}/aread8.txt | 0 .../description/{ => single}/areadinf.txt | 0 .../description/{ => single}/d8flowdir.txt | 0 .../{ => single}/d8flowpathextremeup.txt | 0 .../{ => single}/d8hdisttostrm.txt | 0 .../{ => single}/dinfavalanche.txt | 0 .../{ => single}/dinfconclimaccum.txt | 0 .../{ => single}/dinfdecayaccum.txt | 0 .../description/{ => single}/dinfflowdir.txt | 0 .../description/{ => single}/dinfrevaccum.txt | 0 .../{ => single}/dinfupdependence.txt | 0 .../description/single/gagewatershed.txt | 6 + .../description/single/gagewatershed2.txt | 7 + .../{ => single}/moveoutletstostrm.txt | 0 .../description/{ => single}/pitremove.txt | 0 .../description/single/selectgtthreshold.txt | 6 + .../{ => single}/slopearearatio.txt | 0 .../description/{ => single}/slopeavedown.txt | 0 .../description/{ => single}/streamnet.txt | 0 .../description/{ => single}/threshold.txt | 0 .../algs/taudem/description/single/twi.txt | 6 + .../algs/taudem/dinfdistdown_multi.py | 127 ++++++++++++++++++ .../algs/taudem/dinfdistup_multi.py | 124 +++++++++++++++++ .../algs/taudem/dinftranslimaccum2_multi.py | 122 +++++++++++++++++ .../algs/taudem/dinftranslimaccum_multi.py | 114 ++++++++++++++++ .../algs/taudem/dropanalysis_multi.py | 124 +++++++++++++++++ .../processing/algs/taudem/gridnet_multi.py | 114 ++++++++++++++++ .../algs/taudem/lengtharea_multi.py | 96 +++++++++++++ .../algs/taudem/peukerdouglas_multi.py | 94 +++++++++++++ .../processing/algs/taudem/slopearea_multi.py | 96 +++++++++++++ 56 files changed, 1432 insertions(+), 38 deletions(-) create mode 100644 python/plugins/processing/algs/taudem/TauDEMMultifileAlgorithm.py create mode 100644 python/plugins/processing/algs/taudem/description/multi/aread8.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/areadinf.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/d8flowdir.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/d8flowpathextremeup.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/d8hdisttostrm.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/dinfavalanche.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/dinfconclimaccum.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/dinfdecayaccum.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/dinfflowdir.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/dinfrevaccum.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/dinfupdependence.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/gagewatershed.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/gagewatershed2.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/moveoutletstostrm.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/pitremove.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/selectgtthreshold.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/slopearearatio.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/slopeavedown.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/streamnet.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/threshold.txt create mode 100644 python/plugins/processing/algs/taudem/description/multi/twi.txt rename python/plugins/processing/algs/taudem/description/{ => single}/aread8.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/areadinf.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/d8flowdir.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/d8flowpathextremeup.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/d8hdisttostrm.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/dinfavalanche.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/dinfconclimaccum.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/dinfdecayaccum.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/dinfflowdir.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/dinfrevaccum.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/dinfupdependence.txt (100%) create mode 100644 python/plugins/processing/algs/taudem/description/single/gagewatershed.txt create mode 100644 python/plugins/processing/algs/taudem/description/single/gagewatershed2.txt rename python/plugins/processing/algs/taudem/description/{ => single}/moveoutletstostrm.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/pitremove.txt (100%) create mode 100644 python/plugins/processing/algs/taudem/description/single/selectgtthreshold.txt rename python/plugins/processing/algs/taudem/description/{ => single}/slopearearatio.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/slopeavedown.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/streamnet.txt (100%) rename python/plugins/processing/algs/taudem/description/{ => single}/threshold.txt (100%) create mode 100644 python/plugins/processing/algs/taudem/description/single/twi.txt create mode 100644 python/plugins/processing/algs/taudem/dinfdistdown_multi.py create mode 100644 python/plugins/processing/algs/taudem/dinfdistup_multi.py create mode 100644 python/plugins/processing/algs/taudem/dinftranslimaccum2_multi.py create mode 100644 python/plugins/processing/algs/taudem/dinftranslimaccum_multi.py create mode 100644 python/plugins/processing/algs/taudem/dropanalysis_multi.py create mode 100644 python/plugins/processing/algs/taudem/gridnet_multi.py create mode 100644 python/plugins/processing/algs/taudem/lengtharea_multi.py create mode 100644 python/plugins/processing/algs/taudem/peukerdouglas_multi.py create mode 100644 python/plugins/processing/algs/taudem/slopearea_multi.py diff --git a/python/plugins/processing/algs/taudem/CMakeLists.txt b/python/plugins/processing/algs/taudem/CMakeLists.txt index 7bde62df9b29..ac667d4f0fba 100644 --- a/python/plugins/processing/algs/taudem/CMakeLists.txt +++ b/python/plugins/processing/algs/taudem/CMakeLists.txt @@ -1,5 +1,7 @@ FILE(GLOB PY_FILES *.py) -FILE(GLOB DESCR_FILES description/*.txt) +FILE(GLOB SINGLE_DESCR_FILES description/single/*.txt) +FILE(GLOB MULTI_DESCR_FILES description/multi/*.txt) PLUGIN_INSTALL(processing algs/taudem ${PY_FILES}) -PLUGIN_INSTALL(processing algs/taudem/description ${DESCR_FILES}) +PLUGIN_INSTALL(processing algs/taudem/description/single ${SINGLE_DESCR_FILES}) +PLUGIN_INSTALL(processing algs/taudem/description/multi ${MULTI_DESCR_FILES}) diff --git a/python/plugins/processing/algs/taudem/TauDEMAlgorithm.py b/python/plugins/processing/algs/taudem/TauDEMAlgorithm.py index 8dc61c02df9c..92a127cf409e 100644 --- a/python/plugins/processing/algs/taudem/TauDEMAlgorithm.py +++ b/python/plugins/processing/algs/taudem/TauDEMAlgorithm.py @@ -27,18 +27,21 @@ import os from PyQt4.QtGui import QIcon + from processing.core.GeoAlgorithm import GeoAlgorithm from processing.core.ProcessingLog import ProcessingLog from processing.core.ProcessingConfig import ProcessingConfig from processing.core.GeoAlgorithmExecutionException import \ GeoAlgorithmExecutionException -from processing.core.parameters import getParameterFromString + from processing.core.parameters import ParameterRaster from processing.core.parameters import ParameterVector from processing.core.parameters import ParameterBoolean from processing.core.parameters import ParameterString from processing.core.parameters import ParameterNumber +from processing.core.parameters import getParameterFromString from processing.core.outputs import getOutputFromString + from TauDEMUtils import TauDEMUtils diff --git a/python/plugins/processing/algs/taudem/TauDEMAlgorithmProvider.py b/python/plugins/processing/algs/taudem/TauDEMAlgorithmProvider.py index de3a58e9efd7..2d41ebf97b2b 100644 --- a/python/plugins/processing/algs/taudem/TauDEMAlgorithmProvider.py +++ b/python/plugins/processing/algs/taudem/TauDEMAlgorithmProvider.py @@ -30,11 +30,13 @@ from PyQt4.QtGui import QIcon from processing.core.AlgorithmProvider import AlgorithmProvider -from processing.core.ProcessingConfig import ProcessingConfig -from processing.core.ProcessingConfig import Setting +from processing.core.ProcessingConfig import ProcessingConfig, Setting from processing.core.ProcessingLog import ProcessingLog + from TauDEMAlgorithm import TauDEMAlgorithm +from TauDEMMultifileAlgorithm import TauDEMMultifileAlgorithm from TauDEMUtils import TauDEMUtils + from peukerdouglas import PeukerDouglas from slopearea import SlopeArea from lengtharea import LengthArea @@ -45,13 +47,22 @@ from dinftranslimaccum import DinfTransLimAccum from dinftranslimaccum2 import DinfTransLimAccum2 +from peukerdouglas_multi import PeukerDouglasMulti +from slopearea_multi import SlopeAreaMulti +from lengtharea_multi import LengthAreaMulti +from dropanalysis_multi import DropAnalysisMulti +from dinfdistdown_multi import DinfDistDownMulti +from dinfdistup_multi import DinfDistUpMulti +from gridnet_multi import GridNetMulti +from dinftranslimaccum_multi import DinfTransLimAccumMulti +from dinftranslimaccum2_multi import DinfTransLimAccum2Multi + class TauDEMAlgorithmProvider(AlgorithmProvider): def __init__(self): AlgorithmProvider.__init__(self) self.activate = False - self.createAlgsList() def getDescription(self): return self.tr('TauDEM (hydrologic analysis)') @@ -64,10 +75,21 @@ def getIcon(self): def initializeSettings(self): AlgorithmProvider.initializeSettings(self) + ProcessingConfig.addSetting(Setting(self.getDescription(), TauDEMUtils.TAUDEM_FOLDER, self.tr('TauDEM command line tools folder'), TauDEMUtils.taudemPath())) + ProcessingConfig.addSetting(Setting(self.getDescription(), + TauDEMUtils.TAUDEM_MULTIFILE_FOLDER, + self.tr('TauDEM multifile command line tools folder'), + TauDEMUtils.taudemMultifilePath())) + ProcessingConfig.addSetting(Setting(self.getDescription(), + TauDEMUtils.TAUDEM_USE_SINGLEFILE, + self.tr('Enable singlefile TauDEM tools'), True)) + ProcessingConfig.addSetting(Setting(self.getDescription(), + TauDEMUtils.TAUDEM_USE_MULTIFILE, + self.tr('Enable multifile TauDEM tools'), False)) ProcessingConfig.addSetting(Setting(self.getDescription(), TauDEMUtils.MPIEXEC_FOLDER, self.tr('MPICH2/OpenMPI bin directory'), @@ -78,36 +100,65 @@ def initializeSettings(self): def unload(self): AlgorithmProvider.unload(self) + ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_FOLDER) + ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_MULTIFILE_FOLDER) + ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_USE_SINGLEFILE) + ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_USE_MULTIFILE) ProcessingConfig.removeSetting(TauDEMUtils.MPIEXEC_FOLDER) ProcessingConfig.removeSetting(TauDEMUtils.MPI_PROCESSES) def _loadAlgorithms(self): - self.algs = self.preloadedAlgs - - def createAlgsList(self): - self.preloadedAlgs = [] - folder = TauDEMUtils.taudemDescriptionPath() - for descriptionFile in os.listdir(folder): - if descriptionFile.endswith('txt'): - try: - alg = TauDEMAlgorithm(os.path.join(folder, - descriptionFile)) - if alg.name.strip() != '': - self.preloadedAlgs.append(alg) - else: - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('Could not open TauDEM algorithm: %s' % descriptionFile)) - except Exception, e: - ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, - self.tr('Could not open TauDEM algorithm: %s' % descriptionFile)) - - self.preloadedAlgs.append(PeukerDouglas()) - self.preloadedAlgs.append(SlopeArea()) - self.preloadedAlgs.append(LengthArea()) - self.preloadedAlgs.append(DropAnalysis()) - self.preloadedAlgs.append(DinfDistDown()) - self.preloadedAlgs.append(DinfDistUp()) - self.preloadedAlgs.append(GridNet()) - self.preloadedAlgs.append(DinfTransLimAccum()) - self.preloadedAlgs.append(DinfTransLimAccum2()) + self.algs = [] + basePath = TauDEMUtils.taudemDescriptionPath() + + if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_SINGLEFILE): + folder = os.path.join(basePath, 'single') + + for descriptionFile in os.listdir(folder): + if descriptionFile.endswith('txt'): + descriptionFile = os.path.join(folder, descriptionFile) + self._algFromDescription(descriptionFile) + + self.algs.append(PeukerDouglas()) + self.algs.append(SlopeArea()) + self.algs.append(LengthArea()) + self.algs.append(DropAnalysis()) + self.algs.append(DinfDistDown()) + self.algs.append(DinfDistUp()) + self.algs.append(GridNet()) + self.algs.append(DinfTransLimAccum()) + self.algs.append(DinfTransLimAccum2()) + + if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_MULTIFILE): + folder = os.path.join(basePath, 'multi') + + for descriptionFile in os.listdir(folder): + if descriptionFile.endswith('txt'): + descriptionFile = os.path.join(folder, descriptionFile) + self._algFromDescription(descriptionFile, True) + + self.algs.append(PeukerDouglasMulti()) + self.algs.append(SlopeAreaMulti()) + self.algs.append(LengthAreaMulti()) + self.algs.append(DropAnalysisMulti()) + self.algs.append(DinfDistDownMulti()) + self.algs.append(DinfDistUpMulti()) + self.algs.append(GridNetMulti()) + self.algs.append(DinfTransLimAccumMulti()) + self.algs.append(DinfTransLimAccum2Multi()) + + def _algFromDescription(self, descriptionFile, multifile=False): + try: + if multifile: + alg = TauDEMMultifileAlgorithm(descriptionFile) + else: + alg = TauDEMAlgorithm(descriptionFile) + if alg.name.strip() != '': + self.algs.append(alg) + else: + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, + self.tr('Could not open TauDEM algorithm: %s' % descriptionFile)) + except Exception, e: + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, + self.tr('Could not open TauDEM algorithm %s:\n%s' % (descriptionFile, str(e)))) diff --git a/python/plugins/processing/algs/taudem/TauDEMMultifileAlgorithm.py b/python/plugins/processing/algs/taudem/TauDEMMultifileAlgorithm.py new file mode 100644 index 000000000000..fd54b5beed4f --- /dev/null +++ b/python/plugins/processing/algs/taudem/TauDEMMultifileAlgorithm.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + TauDEMMultifileAlgorithm.py + --------------------- + Date : March 2015 + Copyright : (C) 2012 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingLog import ProcessingLog +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterVector +from processing.core.parameters import ParameterBoolean +from processing.core.parameters import ParameterString +from processing.core.parameters import ParameterNumber +from processing.core.parameters import getParameterFromString +from processing.core.outputs import getOutputFromString + +from TauDEMUtils import TauDEMUtils + + +class TauDEMMultifileAlgorithm(GeoAlgorithm): + + def __init__(self, descriptionfile): + GeoAlgorithm.__init__(self) + self.descriptionFile = descriptionfile + self.defineCharacteristicsFromFile() + + def getCopy(self): + newone = TauDEMMultifileAlgorithm(self.descriptionFile) + newone.provider = self.provider + return newone + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristicsFromFile(self): + lines = open(self.descriptionFile) + line = lines.readline().strip('\n').strip() + self.name = line + line = lines.readline().strip('\n').strip() + self.cmdName = line + line = lines.readline().strip('\n').strip() + self.group = line + + line = lines.readline().strip('\n').strip() + while line != '': + try: + line = line.strip('\n').strip() + if line.startswith('Parameter'): + param = getParameterFromString(line) + self.addParameter(param) + else: + self.addOutput(getOutputFromString(line)) + line = lines.readline().strip('\n').strip() + except Exception, e: + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, + self.tr('Could not load TauDEM algorithm: %s\n%s' % (self.descriptionFile, line))) + raise e + lines.close() + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = int(ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + + for param in self.parameters: + if param.value is None or param.value == '': + continue + if isinstance(param, ParameterNumber): + commands.append(param.name) + commands.append(str(param.value)) + if isinstance(param, (ParameterFile, ParameterVector)): + commands.append(param.name) + commands.append(param.value) + elif isinstance(param, ParameterBoolean): + if param.value and str(param.value).lower() == 'false': + commands.append(param.name) + elif isinstance(param, ParameterString): + commands.append(param.name) + commands.append(str(param.value)) + + for out in self.outputs: + commands.append(out.name) + commands.append(out.value) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/TauDEMUtils.py b/python/plugins/processing/algs/taudem/TauDEMUtils.py index dc3789a7e607..48150cef069f 100644 --- a/python/plugins/processing/algs/taudem/TauDEMUtils.py +++ b/python/plugins/processing/algs/taudem/TauDEMUtils.py @@ -26,18 +26,22 @@ __revision__ = '$Format:%H$' import os -from qgis.core import QgsApplication import subprocess +from PyQt4.QtCore import QCoreApplication +from qgis.core import QgsApplication + from processing.core.ProcessingConfig import ProcessingConfig from processing.core.ProcessingLog import ProcessingLog from processing.tools.system import isMac -from PyQt4.QtCore import QCoreApplication class TauDEMUtils: TAUDEM_FOLDER = 'TAUDEM_FOLDER' + TAUDEM_MULTIFILE_FOLDER = 'TAUDEM_MULTIFILE_FOLDER' + TAUDEM_USE_SINGLEFILE = 'TAUDEM_USE_SINGLEFILE' + TAUDEM_USE_MULTIFILE = 'TAUDEM_USE_MULTIFILE' MPIEXEC_FOLDER = 'MPIEXEC_FOLDER' MPI_PROCESSES = 'MPI_PROCESSES' @@ -57,6 +61,22 @@ def taudemPath(): folder = testfolder return folder + @staticmethod + def taudemMultifilePath(): + folder = ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_MULTIFILE_FOLDER) + if folder is None: + folder = '' + + if isMac(): + testfolder = os.path.join(QgsApplication.prefixPath(), 'bin') + if os.path.exists(os.path.join(testfolder, 'slopearea')): + folder = testfolder + else: + testfolder = '/usr/local/bin' + if os.path.exists(os.path.join(testfolder, 'slopearea')): + folder = testfolder + return folder + @staticmethod def mpiexecPath(): folder = ProcessingConfig.getSetting(TauDEMUtils.MPIEXEC_FOLDER) @@ -75,8 +95,8 @@ def mpiexecPath(): @staticmethod def taudemDescriptionPath(): - return os.path.normpath(os.path.join(os.path.dirname(__file__), - 'description')) + return os.path.normpath( + os.path.join(os.path.dirname(__file__), 'description')) @staticmethod def executeTauDEM(command, progress): diff --git a/python/plugins/processing/algs/taudem/description/multi/aread8.txt b/python/plugins/processing/algs/taudem/description/multi/aread8.txt new file mode 100644 index 000000000000..b2cb7308bf7d --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/aread8.txt @@ -0,0 +1,8 @@ +D8 Contributing Area (multifile) +aread8 +Basic Grid Analysis tools +ParameterFile|-p|D8 Flow Direction Grid|True|False +ParameterVector|-o|Outlets Shapefile|0|True +ParameterFile|-wg|Weight Grid|True|True +ParameterBoolean|-nc|Check for edge contamination|True +OutputDirectory|-ad8|D8 Contributing Area Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/areadinf.txt b/python/plugins/processing/algs/taudem/description/multi/areadinf.txt new file mode 100644 index 000000000000..de64be2c923e --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/areadinf.txt @@ -0,0 +1,8 @@ +D-Infinity Contributing Area (multifile) +areadinf +Basic Grid Analysis tools +ParameterFile|-ang|D-Infinity Flow Direction Grid|True|False +ParameterVector|-o|Outlets Shapefile|0|True +ParameterFile|-wg|Weight Grid|True|True +ParameterBoolean|-nc|Check for edge contamination|True +OutputDirectory|-sca|D-Infinity Specific Catchment Area Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/d8flowdir.txt b/python/plugins/processing/algs/taudem/description/multi/d8flowdir.txt new file mode 100644 index 000000000000..96666a7765ee --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/d8flowdir.txt @@ -0,0 +1,6 @@ +D8 Flow Directions (multifile) +d8flowdir +Basic Grid Analysis tools +ParameterFile|-fel|Pit Filled Elevation Grid|True|False +OutputDirectory|-p|D8 Flow Direction Grid +OutputDirectory|-sd8|D8 Slope Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/d8flowpathextremeup.txt b/python/plugins/processing/algs/taudem/description/multi/d8flowpathextremeup.txt new file mode 100644 index 000000000000..91da81297721 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/d8flowpathextremeup.txt @@ -0,0 +1,9 @@ +D8 Extreme Upslope Value (multifile) +d8flowpathextremeup +Stream Network Analysis tools +ParameterFile|-p|D8 Flow Directions Grid|True|False +ParameterFile|-sa|Upslope Values Grid|True|False +ParameterVector|-o|Outlets Shapefile|0|True +ParameterBoolean|-nc|Check for edge contamination|True +ParameterBoolean|-min|Use max upslope value|True +OutputDirectory|-ssa|Extereme Upslope Values Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/d8hdisttostrm.txt b/python/plugins/processing/algs/taudem/description/multi/d8hdisttostrm.txt new file mode 100644 index 000000000000..9b7fe53cb5e8 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/d8hdisttostrm.txt @@ -0,0 +1,7 @@ +D8 Distance To Streams (multifile) +d8hdisttostrm +Specialized Grid Analysis tools +ParameterFile|-p|D8 Flow Direction Grid|True|False +ParameterFile|-src|Stream Raster Grid|True|False +ParameterNumber|-thresh|Threshold|1|500|50 +OutputDirectory|-dist|Output Distance to Streams diff --git a/python/plugins/processing/algs/taudem/description/multi/dinfavalanche.txt b/python/plugins/processing/algs/taudem/description/multi/dinfavalanche.txt new file mode 100644 index 000000000000..169751399d8d --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/dinfavalanche.txt @@ -0,0 +1,11 @@ +D-Infinity Avalanche Runout (multifile) +dinfavalanche +Specialized Grid Analysis tools +ParameterFile|-ang|D-Infinity Flow Direction Grid|True|False +ParameterFile|-fel|Pit Filled Elevation Grid|True|False +ParameterFile|-ass|Avalanche Source Site Grid|True|False +ParameterNumber|-thresh|Proportion Threshold|0.00001|10.0|0.2 +ParameterNumber|-alpha|Alpha Angle Threshold|0|360|18 +ParameterBoolean|-direct|Measure distance along flow path|True +OutputDirectory|-rz|Runout Zone Grid +OutputDirectory|-dfs|Path Distance Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/dinfconclimaccum.txt b/python/plugins/processing/algs/taudem/description/multi/dinfconclimaccum.txt new file mode 100644 index 000000000000..a543770b5fde --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/dinfconclimaccum.txt @@ -0,0 +1,11 @@ +D-Infinity Concentration Limited Accumulation (multifile) +dinfconclimaccum +Specialized Grid Analysis tools +ParameterFile|-ang|D-Infinity Flow Direction Grid|True|False +ParameterFile|-dg|Disturbance Indicator Grid|True|False +ParameterFile|-dm|Decay Multiplier Grid|True|False +ParameterFile|-q|Effective Runoff Weight Grid|True|False +ParameterVector|-o|Outlets shapefile|0|True +ParameterNumber|-csol|Concentration Threshold|1.0|100.0|1.0 +ParameterBoolean|-nc|Check for edge contamination|True +OutputDirectory|-ctpt|Concentration Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/dinfdecayaccum.txt b/python/plugins/processing/algs/taudem/description/multi/dinfdecayaccum.txt new file mode 100644 index 000000000000..26552f3e3647 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/dinfdecayaccum.txt @@ -0,0 +1,9 @@ +D-Infinity Decaying Accumulation +dinfdecayaccum +Specialized Grid Analysis tools +ParameterFile|-ang|D-Infinity Flow Direction Grid|True|False +ParameterFile|-dm|Decay Multiplier Grid|True|False +ParameterFile|-wg|Weight Grid|True|True +ParameterVector|-o|Outlets Shapefile|0|True +ParameterBoolean|-nc|Check for edge contamination|True +OutputDirectory|-dsca|Decayed Specific Catchment Area Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/dinfflowdir.txt b/python/plugins/processing/algs/taudem/description/multi/dinfflowdir.txt new file mode 100644 index 000000000000..738e77d0e1f4 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/dinfflowdir.txt @@ -0,0 +1,6 @@ +D-Infinity Flow Directions (multifile) +dinfflowdir +Basic Grid Analysis tools +ParameterFile|-fel|Pit Filled Elevation Grid|True|False +OutputDirectory|-ang|D-Infinity Flow Directions Grid +OutputDirectory|-slp|D-Infinity Slope Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/dinfrevaccum.txt b/python/plugins/processing/algs/taudem/description/multi/dinfrevaccum.txt new file mode 100644 index 000000000000..06b64249520f --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/dinfrevaccum.txt @@ -0,0 +1,7 @@ +D-Infinity Reverse Accumulation (multifile) +dinfrevaccum +Specialized Grid Analysis tools +ParameterFile|-ang|D-Infinity Flow Direction Grid|True|False +ParameterFile|-wg|Weight Grid|True|False +OutputDirectory|-racc|Reverse Accumulation Grid +OutputDirectory|-dmax|Maximum Downslope Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/dinfupdependence.txt b/python/plugins/processing/algs/taudem/description/multi/dinfupdependence.txt new file mode 100644 index 000000000000..5ec65a369036 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/dinfupdependence.txt @@ -0,0 +1,6 @@ +D-Infinity Upslope Dependence (multifile) +dinfupdependence +Specialized Grid Analysis tools +ParameterFile|-ang|D-Infinity Flow Direction Grid|True|False +ParameterFile|-dg|Destination Grid|True|False +OutputDirectory|-dep|Output Upslope Dependence Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/gagewatershed.txt b/python/plugins/processing/algs/taudem/description/multi/gagewatershed.txt new file mode 100644 index 000000000000..1f44c32d5531 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/gagewatershed.txt @@ -0,0 +1,6 @@ +Gage Watershed (multifile) +gagewatershed +Stream Network Analysis tools +ParameterRaster|-p|D8 Flow Directions Grid|False +ParameterVector|-o|Gages Shapefile|0|False +OutputRaster|-gw|Gage Watershed Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/gagewatershed2.txt b/python/plugins/processing/algs/taudem/description/multi/gagewatershed2.txt new file mode 100644 index 000000000000..9a9130034437 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/gagewatershed2.txt @@ -0,0 +1,7 @@ +Gage Watershed - 2 (multifile) +gagewatershed +Stream Network Analysis tools +ParameterRaster|-p|D8 Flow Directions Grid|False +ParameterVector|-o|Gages Shapefile|0|False +OutputRaster|-gw|Gage Watershed Grid +OutputFile|-id|Downstream Identifiers File diff --git a/python/plugins/processing/algs/taudem/description/multi/moveoutletstostrm.txt b/python/plugins/processing/algs/taudem/description/multi/moveoutletstostrm.txt new file mode 100644 index 000000000000..07f34839d8a3 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/moveoutletstostrm.txt @@ -0,0 +1,8 @@ +Move Outlets To Streams (multifile) +moveoutletstostrm +Stream Network Analysis tools +ParameterFile|-p|D8 Flow Direction Grid|True|False +ParameterFile|-src|Stream Raster Grid|True|False +ParameterVector|-o|Outlets Shapefile|0|False +ParameterNumber|-md|Maximum Number of Grid Cells to traverse|1|500|50 +OutputVector|-om|Output Outlet Shapefile diff --git a/python/plugins/processing/algs/taudem/description/multi/pitremove.txt b/python/plugins/processing/algs/taudem/description/multi/pitremove.txt new file mode 100644 index 000000000000..2eedd409130c --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/pitremove.txt @@ -0,0 +1,5 @@ +Pit Remove (multifile) +pitremove +Basic Grid Analysis tools +ParameterFile|-z|Elevation Grid|True|False +OutputDirectory|-fel|Pit Removed Elevation Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/selectgtthreshold.txt b/python/plugins/processing/algs/taudem/description/multi/selectgtthreshold.txt new file mode 100644 index 000000000000..ade45dafffdc --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/selectgtthreshold.txt @@ -0,0 +1,6 @@ +Select GT Threshold (multifile) +selectgtthreshold +Basic Grid Analysis tools +ParameterRaster|-z|Elevation Grid|False +ParameterNumber|-thresh|Threshold|0.0|999999.999999|0.0 +OutputRaster|-t|Output Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/slopearearatio.txt b/python/plugins/processing/algs/taudem/description/multi/slopearearatio.txt new file mode 100644 index 000000000000..ecfcd1c18435 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/slopearearatio.txt @@ -0,0 +1,6 @@ +Slope Over Area Ratio (multifile) +slopearearatio +Specialized Grid Analysis tools +ParameterFile|-slp|Slope Grid|True|False +ParameterFile|-sca|Specific Catchment Area Grid|True|False +OutputDirectory|-sar|Slope Divided By Area Ratio Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/slopeavedown.txt b/python/plugins/processing/algs/taudem/description/multi/slopeavedown.txt new file mode 100644 index 000000000000..4ccbb93aaa80 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/slopeavedown.txt @@ -0,0 +1,7 @@ +Slope Average Down (multifile) +slopeavedown +Specialized Grid Analysis tools +ParameterFile|-p|D8 Flow Direction Grid|True|False +ParameterFile|-fel|Pit Filled Elevation Grid|True|False +ParameterNumber|-dn|Downslope Distance|1|500|50 +OutputDirectory|-slpd|Slope Average Down Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/streamnet.txt b/python/plugins/processing/algs/taudem/description/multi/streamnet.txt new file mode 100644 index 000000000000..ff6360f8b265 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/streamnet.txt @@ -0,0 +1,14 @@ +Stream Reach and Watershed (multifile) +streamnet +Stream Network Analysis tools +ParameterFile|-fel|Pit Filled Elevation Grid|True|False +ParameterFile|-p|D8 Flow Direction Grid|True|False +ParameterFile|-ad8|D8 Drainage Area|True|False +ParameterFile|-src|Stream Raster Grid|True|False +ParameterVector|-o|Outlets Shapefile as Network Nodes|0|True +ParameterBoolean|-sw|Delineate Single Watershed|False +OutputDirectory|-ord|Stream Order Grid +OutputDirectory|-w|Watershed Grid +OutputVector|-net|Stream Reach Shapefile +OutputFile|-tree|Network Connectivity Tree +OutputFile|-coord|Network Coordinates diff --git a/python/plugins/processing/algs/taudem/description/multi/threshold.txt b/python/plugins/processing/algs/taudem/description/multi/threshold.txt new file mode 100644 index 000000000000..02ea9d5744f3 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/threshold.txt @@ -0,0 +1,7 @@ +Stream Definition By Threshold (multifile) +threshold +Stream Network Analysis tools +ParameterFile|-ssa|Accumulated Stream Source Grid|True|False +ParameterNumber|-thresh|Threshold|1|None|100 +ParameterFile|-mask|Mask Grid|True|True +OutputDirectory|-src|Stream Raster Grid diff --git a/python/plugins/processing/algs/taudem/description/multi/twi.txt b/python/plugins/processing/algs/taudem/description/multi/twi.txt new file mode 100644 index 000000000000..47f2545c4a01 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/multi/twi.txt @@ -0,0 +1,6 @@ +Topographic Wetness Index (multifile) +twi +Stream Network Analysis tools +ParameterRaster|-sca|D-Infinity Specific Catchment Area Grid|False +ParameterRaster|-slp|D-Infinity Slope Grid|False +OutputRaster|-twi|Topographic Wetness Index Grid diff --git a/python/plugins/processing/algs/taudem/description/aread8.txt b/python/plugins/processing/algs/taudem/description/single/aread8.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/aread8.txt rename to python/plugins/processing/algs/taudem/description/single/aread8.txt diff --git a/python/plugins/processing/algs/taudem/description/areadinf.txt b/python/plugins/processing/algs/taudem/description/single/areadinf.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/areadinf.txt rename to python/plugins/processing/algs/taudem/description/single/areadinf.txt diff --git a/python/plugins/processing/algs/taudem/description/d8flowdir.txt b/python/plugins/processing/algs/taudem/description/single/d8flowdir.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/d8flowdir.txt rename to python/plugins/processing/algs/taudem/description/single/d8flowdir.txt diff --git a/python/plugins/processing/algs/taudem/description/d8flowpathextremeup.txt b/python/plugins/processing/algs/taudem/description/single/d8flowpathextremeup.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/d8flowpathextremeup.txt rename to python/plugins/processing/algs/taudem/description/single/d8flowpathextremeup.txt diff --git a/python/plugins/processing/algs/taudem/description/d8hdisttostrm.txt b/python/plugins/processing/algs/taudem/description/single/d8hdisttostrm.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/d8hdisttostrm.txt rename to python/plugins/processing/algs/taudem/description/single/d8hdisttostrm.txt diff --git a/python/plugins/processing/algs/taudem/description/dinfavalanche.txt b/python/plugins/processing/algs/taudem/description/single/dinfavalanche.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/dinfavalanche.txt rename to python/plugins/processing/algs/taudem/description/single/dinfavalanche.txt diff --git a/python/plugins/processing/algs/taudem/description/dinfconclimaccum.txt b/python/plugins/processing/algs/taudem/description/single/dinfconclimaccum.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/dinfconclimaccum.txt rename to python/plugins/processing/algs/taudem/description/single/dinfconclimaccum.txt diff --git a/python/plugins/processing/algs/taudem/description/dinfdecayaccum.txt b/python/plugins/processing/algs/taudem/description/single/dinfdecayaccum.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/dinfdecayaccum.txt rename to python/plugins/processing/algs/taudem/description/single/dinfdecayaccum.txt diff --git a/python/plugins/processing/algs/taudem/description/dinfflowdir.txt b/python/plugins/processing/algs/taudem/description/single/dinfflowdir.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/dinfflowdir.txt rename to python/plugins/processing/algs/taudem/description/single/dinfflowdir.txt diff --git a/python/plugins/processing/algs/taudem/description/dinfrevaccum.txt b/python/plugins/processing/algs/taudem/description/single/dinfrevaccum.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/dinfrevaccum.txt rename to python/plugins/processing/algs/taudem/description/single/dinfrevaccum.txt diff --git a/python/plugins/processing/algs/taudem/description/dinfupdependence.txt b/python/plugins/processing/algs/taudem/description/single/dinfupdependence.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/dinfupdependence.txt rename to python/plugins/processing/algs/taudem/description/single/dinfupdependence.txt diff --git a/python/plugins/processing/algs/taudem/description/single/gagewatershed.txt b/python/plugins/processing/algs/taudem/description/single/gagewatershed.txt new file mode 100644 index 000000000000..cc9e3d90186e --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/single/gagewatershed.txt @@ -0,0 +1,6 @@ +Gage Watershed +gagewatershed +Stream Network Analysis tools +ParameterRaster|-p|D8 Flow Directions Grid|False +ParameterVector|-o|Gages Shapefile|0|False +OutputRaster|-gw|Gage Watershed Grid diff --git a/python/plugins/processing/algs/taudem/description/single/gagewatershed2.txt b/python/plugins/processing/algs/taudem/description/single/gagewatershed2.txt new file mode 100644 index 000000000000..224f1371d325 --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/single/gagewatershed2.txt @@ -0,0 +1,7 @@ +Gage Watershed - 2 +gagewatershed +Stream Network Analysis tools +ParameterRaster|-p|D8 Flow Directions Grid|False +ParameterVector|-o|Gages Shapefile|0|False +OutputRaster|-gw|Gage Watershed Grid +OutputFile|-id|Downstream Identifiers File diff --git a/python/plugins/processing/algs/taudem/description/moveoutletstostrm.txt b/python/plugins/processing/algs/taudem/description/single/moveoutletstostrm.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/moveoutletstostrm.txt rename to python/plugins/processing/algs/taudem/description/single/moveoutletstostrm.txt diff --git a/python/plugins/processing/algs/taudem/description/pitremove.txt b/python/plugins/processing/algs/taudem/description/single/pitremove.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/pitremove.txt rename to python/plugins/processing/algs/taudem/description/single/pitremove.txt diff --git a/python/plugins/processing/algs/taudem/description/single/selectgtthreshold.txt b/python/plugins/processing/algs/taudem/description/single/selectgtthreshold.txt new file mode 100644 index 000000000000..e3a307feab7f --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/single/selectgtthreshold.txt @@ -0,0 +1,6 @@ +Select GT Threshold +selectgtthreshold +Basic Grid Analysis tools +ParameterRaster|-z|Elevation Grid|False +ParameterNumber|-thresh|Threshold|0.0|999999.999999|0.0 +OutputRaster|-t|Output Grid diff --git a/python/plugins/processing/algs/taudem/description/slopearearatio.txt b/python/plugins/processing/algs/taudem/description/single/slopearearatio.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/slopearearatio.txt rename to python/plugins/processing/algs/taudem/description/single/slopearearatio.txt diff --git a/python/plugins/processing/algs/taudem/description/slopeavedown.txt b/python/plugins/processing/algs/taudem/description/single/slopeavedown.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/slopeavedown.txt rename to python/plugins/processing/algs/taudem/description/single/slopeavedown.txt diff --git a/python/plugins/processing/algs/taudem/description/streamnet.txt b/python/plugins/processing/algs/taudem/description/single/streamnet.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/streamnet.txt rename to python/plugins/processing/algs/taudem/description/single/streamnet.txt diff --git a/python/plugins/processing/algs/taudem/description/threshold.txt b/python/plugins/processing/algs/taudem/description/single/threshold.txt similarity index 100% rename from python/plugins/processing/algs/taudem/description/threshold.txt rename to python/plugins/processing/algs/taudem/description/single/threshold.txt diff --git a/python/plugins/processing/algs/taudem/description/single/twi.txt b/python/plugins/processing/algs/taudem/description/single/twi.txt new file mode 100644 index 000000000000..e4f10d7de31b --- /dev/null +++ b/python/plugins/processing/algs/taudem/description/single/twi.txt @@ -0,0 +1,6 @@ +Topographic Wetness Index +twi +Stream Network Analysis tools +ParameterRaster|-sca|D-Infinity Specific Catchment Area Grid|False +ParameterRaster|-slp|D-Infinity Slope Grid|False +OutputRaster|-twi|Topographic Wetness Index Grid diff --git a/python/plugins/processing/algs/taudem/dinfdistdown_multi.py b/python/plugins/processing/algs/taudem/dinfdistdown_multi.py new file mode 100644 index 000000000000..9988532109c4 --- /dev/null +++ b/python/plugins/processing/algs/taudem/dinfdistdown_multi.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + dinfdistdown_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterBoolean +from processing.core.parameters import ParameterSelection +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class DinfDistDownMulti(GeoAlgorithm): + + DINF_FLOW_DIR_GRID = 'DINF_FLOW_DIR_GRID' + PIT_FILLED_GRID = 'PIT_FILLED_GRID' + STREAM_GRID = 'STREAM_GRID' + WEIGHT_PATH_GRID = 'WEIGHT_PATH_GRID' + STAT_METHOD = 'STAT_METHOD' + DIST_METHOD = 'DIST_METHOD' + EDGE_CONTAM = 'EDGE_CONTAM' + + DIST_DOWN_GRID = 'DIST_DOWN_GRID' + + STATISTICS = ['Minimum', 'Maximum', 'Average'] + STAT_DICT = {0: 'min', 1: 'max', 2: 'ave'} + + DISTANCE = ['Pythagoras', 'Horizontal', 'Vertical', 'Surface'] + DIST_DICT = { + 0: 'p', + 1: 'h', + 2: 'v', + 3: 's', + } + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'D-Infinity Distance Down (multifile)' + self.cmdName = 'dinfdistdown' + self.group = 'Specialized Grid Analysis tools' + + self.addParameter(ParameterFile(self.DINF_FLOW_DIR_GRID, + self.tr('D-Infinity Flow Direction Grid'), True, False)) + self.addParameter(ParameterFile(self.PIT_FILLED_GRID, + self.tr('Pit Filled Elevation Grid'), True, False)) + self.addParameter(ParameterFile(self.STREAM_GRID, + self.tr('Stream Raster Grid'), True, False)) + self.addParameter(ParameterFile(self.WEIGHT_PATH_GRID, + self.tr('Weight Path Grid'), True, True)) + self.addParameter(ParameterSelection(self.STAT_METHOD, + self.tr('Statistical Method'), self.STATISTICS, 2)) + self.addParameter(ParameterSelection(self.DIST_METHOD, + self.tr('Distance Method'), self.DISTANCE, 1)) + self.addParameter(ParameterBoolean(self.EDGE_CONTAM, + self.tr('Check for edge contamination'), True)) + + self.addOutput(OutputDirectory(self.DIST_DOWN_GRID, + self.tr('D-Infinity Drop to Stream Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-ang') + commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) + commands.append('-fel') + commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) + commands.append('-src') + commands.append(self.getParameterValue(self.STREAM_GRID)) + wg = self.getParameterValue(self.WEIGHT_PATH_GRID) + if wg is not None: + commands.append('-wg') + commands.append(self.getParameterValue(self.WEIGHT_PATH_GRID)) + commands.append('-m') + commands.append(str(self.STAT_DICT[self.getParameterValue( + self.STAT_METHOD)])) + commands.append(str(self.DIST_DICT[self.getParameterValue( + self.DIST_METHOD)])) + if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': + commands.append('-nc') + commands.append('-dd') + commands.append(self.getOutputValue(self.DIST_DOWN_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/dinfdistup_multi.py b/python/plugins/processing/algs/taudem/dinfdistup_multi.py new file mode 100644 index 000000000000..b659c5ee68cd --- /dev/null +++ b/python/plugins/processing/algs/taudem/dinfdistup_multi.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + dinfdistup_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterNumber +from processing.core.parameters import ParameterBoolean +from processing.core.parameters import ParameterSelection +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class DinfDistUpMulti(GeoAlgorithm): + + DINF_FLOW_DIR_GRID = 'DINF_FLOW_DIR_GRID' + PIT_FILLED_GRID = 'PIT_FILLED_GRID' + SLOPE_GRID = 'SLOPE_GRID' + THRESHOLD = 'THRESHOLD' + STAT_METHOD = 'STAT_METHOD' + DIST_METHOD = 'DIST_METHOD' + EDGE_CONTAM = 'EDGE_CONTAM' + + DIST_UP_GRID = 'DIST_UP_GRID' + + STATISTICS = ['Minimum', 'Maximum', 'Average'] + STAT_DICT = {0: 'min', 1: 'max', 2: 'ave'} + + DISTANCE = ['Pythagoras', 'Horizontal', 'Vertical', 'Surface'] + DIST_DICT = { + 0: 'p', + 1: 'h', + 2: 'v', + 3: 's', + } + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'D-Infinity Distance Up (multifile)' + self.cmdName = 'dinfdistup' + self.group = 'Specialized Grid Analysis tools' + + self.addParameter(ParameterFile(self.DINF_FLOW_DIR_GRID, + self.tr('D-Infinity Flow Direction Grid'), True, False)) + self.addParameter(ParameterFile(self.PIT_FILLED_GRID, + self.tr('Pit Filled Elevation Grid'), True, False)) + self.addParameter(ParameterFile(self.SLOPE_GRID, + self.tr('Slope Grid'), True, False)) + self.addParameter(ParameterSelection(self.STAT_METHOD, + self.tr('Statistical Method'), self.STATISTICS, 2)) + self.addParameter(ParameterSelection(self.DIST_METHOD, + self.tr('Distance Method'), self.DISTANCE, 1)) + self.addParameter(ParameterNumber(self.THRESHOLD, + self.tr('Proportion Threshold'), 0, None, 0.5)) + self.addParameter(ParameterBoolean(self.EDGE_CONTAM, + self.tr('Check for edge contamination'), True)) + + self.addOutput(OutputDirectory(self.DIST_UP_GRID, + self.tr('D-Infinity Distance Up'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-ang') + commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) + commands.append('-fel') + commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) + commands.append('-m') + commands.append(str(self.STAT_DICT[self.getParameterValue( + self.STAT_METHOD)])) + commands.append(str(self.DIST_DICT[self.getParameterValue( + self.DIST_METHOD)])) + commands.append('-thresh') + commands.append(str(self.getParameterValue(self.THRESHOLD))) + if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': + commands.append('-nc') + commands.append('-du') + commands.append(self.getOutputValue(self.DIST_UP_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/dinftranslimaccum2_multi.py b/python/plugins/processing/algs/taudem/dinftranslimaccum2_multi.py new file mode 100644 index 000000000000..b824b9957de5 --- /dev/null +++ b/python/plugins/processing/algs/taudem/dinftranslimaccum2_multi.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + dinftranslimaccum2_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterVector +from processing.core.parameters import ParameterBoolean +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class DinfTransLimAccum2Multi(GeoAlgorithm): + + DINF_FLOW_DIR_GRID = 'DINF_FLOW_DIR_GRID' + SUPPLY_GRID = 'SUPPLY_GRID' + CAPACITY_GRID = 'CAPACITY_GRID' + IN_CONCENTR_GRID = 'IN_CONCENTR_GRID' + OUTLETS_SHAPE = 'OUTLETS_SHAPE' + EDGE_CONTAM = 'EDGE_CONTAM' + + TRANSP_LIM_ACCUM_GRID = 'TRANSP_LIM_ACCUM_GRID' + DEPOSITION_GRID = 'DEPOSITION_GRID' + OUT_CONCENTR_GRID = 'OUT_CONCENTR_GRID' + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'D-Infinity Transport Limited Accumulation - 2 (multifile)' + self.cmdName = 'dinftranslimaccum' + self.group = 'Specialized Grid Analysis tools' + + self.addParameter(ParameterFile(self.DINF_FLOW_DIR_GRID, + self.tr('D-Infinity Flow Direction Grid'), True, False)) + self.addParameter(ParameterFile(self.SUPPLY_GRID, + self.tr('Supply Grid'), True, False)) + self.addParameter(ParameterFile(self.CAPACITY_GRID, + self.tr('Transport Capacity Grid'), True, False)) + self.addParameter(ParameterFile(self.IN_CONCENTR_GRID, + self.tr('Input Concentration Grid'), True, False)) + self.addParameter(ParameterVector(self.OUTLETS_SHAPE, + self.tr('Outlets Shapefile'), + [ParameterVector.VECTOR_TYPE_POINT], True)) + self.addParameter(ParameterBoolean(self.EDGE_CONTAM, + self.tr('Check for edge contamination'), True)) + + self.addOutput(OutputDirectory(self.TRANSP_LIM_ACCUM_GRID, + self.tr('Transport Limited Accumulation Grid'))) + self.addOutput(OutputDirectory(self.DEPOSITION_GRID, + self.tr('Deposition Grid'))) + self.addOutput(OutputDirectory(self.OUT_CONCENTR_GRID, + self.tr('Output Concentration Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-ang') + commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) + commands.append('-tsup') + commands.append(self.getParameterValue(self.SUPPLY_GRID)) + commands.append('-tc') + commands.append(self.getParameterValue(self.CAPACITY_GRID)) + commands.append('-cs') + commands.append(self.getParameterValue(self.IN_CONCENTR_GRID)) + param = self.getParameterValue(self.OUTLETS_SHAPE) + if param is not None: + commands.append('-o') + commands.append(param) + if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': + commands.append('-nc') + + commands.append('-tla') + commands.append(self.getOutputValue(self.TRANSP_LIM_ACCUM_GRID)) + commands.append('-tdep') + commands.append(self.getOutputValue(self.DEPOSITION_GRID)) + commands.append('-ctpt') + commands.append(self.getOutputValue(self.OUT_CONCENTR_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/dinftranslimaccum_multi.py b/python/plugins/processing/algs/taudem/dinftranslimaccum_multi.py new file mode 100644 index 000000000000..e8772119f15d --- /dev/null +++ b/python/plugins/processing/algs/taudem/dinftranslimaccum_multi.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + dinftranslimaccum_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterVector +from processing.core.parameters import ParameterBoolean +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class DinfTransLimAccumMulti(GeoAlgorithm): + + DINF_FLOW_DIR_GRID = 'DINF_FLOW_DIR_GRID' + SUPPLY_GRID = 'SUPPLY_GRID' + CAPACITY_GRID = 'CAPACITY_GRID' + IN_CONCENTR_GRID = 'IN_CONCENTR_GRID' + OUTLETS_SHAPE = 'OUTLETS_SHAPE' + EDGE_CONTAM = 'EDGE_CONTAM' + + TRANSP_LIM_ACCUM_GRID = 'TRANSP_LIM_ACCUM_GRID' + DEPOSITION_GRID = 'DEPOSITION_GRID' + OUT_CONCENTR_GRID = 'OUT_CONCENTR_GRID' + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'D-Infinity Transport Limited Accumulation (multifile)' + self.cmdName = 'dinftranslimaccum' + self.group = 'Specialized Grid Analysis tools' + + self.addParameter(ParameterFile(self.DINF_FLOW_DIR_GRID, + self.tr('D-Infinity Flow Direction Grid'), True, False)) + self.addParameter(ParameterFile(self.SUPPLY_GRID, + self.tr('Supply Grid'), True, False)) + self.addParameter(ParameterFile(self.CAPACITY_GRID, + self.tr('Transport Capacity Grid'), True, False)) + self.addParameter(ParameterVector(self.OUTLETS_SHAPE, + self.tr('Outlets Shapefile'), + [ParameterVector.VECTOR_TYPE_POINT], True)) + self.addParameter(ParameterBoolean(self.EDGE_CONTAM, + self.tr('Check for edge contamination'), True)) + + self.addOutput(OutputDirectory(self.TRANSP_LIM_ACCUM_GRID, + self.tr('Transport Limited Accumulation Grid'))) + self.addOutput(OutputDirectory(self.DEPOSITION_GRID, + self.tr('Deposition Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-ang') + commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) + commands.append('-tsup') + commands.append(self.getParameterValue(self.SUPPLY_GRID)) + commands.append('-tc') + commands.append(self.getParameterValue(self.CAPACITY_GRID)) + param = self.getParameterValue(self.OUTLETS_SHAPE) + if param is not None: + commands.append('-o') + commands.append(param) + if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': + commands.append('-nc') + + commands.append('-tla') + commands.append(self.getOutputValue(self.TRANSP_LIM_ACCUM_GRID)) + commands.append('-tdep') + commands.append(self.getOutputValue(self.DEPOSITION_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/dropanalysis_multi.py b/python/plugins/processing/algs/taudem/dropanalysis_multi.py new file mode 100644 index 000000000000..07ca9402e471 --- /dev/null +++ b/python/plugins/processing/algs/taudem/dropanalysis_multi.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + dropanalysis_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterVector +from processing.core.parameters import ParameterNumber +from processing.core.parameters import ParameterSelection +from processing.core.outputs import OutputFile + +from TauDEMUtils import TauDEMUtils + + +class DropAnalysisMulti(GeoAlgorithm): + + PIT_FILLED_GRID = 'PIT_FILLED_GRID' + D8_CONTRIB_AREA_GRID = 'D8_CONTRIB_AREA_GRID' + D8_FLOW_DIR_GRID = 'D8_FLOW_DIR_GRID' + ACCUM_STREAM_SOURCE_GRID = 'ACCUM_STREAM_SOURCE_GRID' + OUTLETS_SHAPE = 'OUTLETS_SHAPE' + MIN_TRESHOLD = 'MIN_TRESHOLD' + MAX_THRESHOLD = 'MAX_THRESHOLD' + TRESHOLD_NUM = 'TRESHOLD_NUM' + STEP_TYPE = 'STEP_TYPE' + + DROP_ANALYSIS_FILE = 'DROP_ANALYSIS_FILE' + + STEPS = ['Logarithmic', 'Linear'] + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'Stream Drop Analysis (multifile)' + self.cmdName = 'dropanalysis' + self.group = 'Stream Network Analysis tools' + + self.addParameter(ParameterFile(self.D8_CONTRIB_AREA_GRID, + self.tr('D8 Contributing Area Grid'), True, False)) + self.addParameter(ParameterFile(self.D8_FLOW_DIR_GRID, + self.tr('D8 Flow Direction Grid'), True, False)) + self.addParameter(ParameterFile(self.PIT_FILLED_GRID, + self.tr('Pit Filled Elevation Grid'), True, False)) + self.addParameter(ParameterFile(self.ACCUM_STREAM_SOURCE_GRID, + self.tr('Accumulated Stream Source Grid'), True, False)) + self.addParameter(ParameterVector(self.OUTLETS_SHAPE, + self.tr('Outlets Shapefile'), + [ParameterVector.VECTOR_TYPE_POINT], False)) + self.addParameter(ParameterNumber(self.MIN_TRESHOLD, + self.tr('Minimum Threshold'), 0, None, 5)) + self.addParameter(ParameterNumber(self.MAX_THRESHOLD, + self.tr('Maximum Threshold'), 0, None, 500)) + self.addParameter(ParameterNumber(self.TRESHOLD_NUM, + self.tr('Number of Threshold Values'), 0, None, 10)) + self.addParameter(ParameterSelection(self.STEP_TYPE, + self.tr('Spacing for Threshold Values'), self.STEPS, 0)) + + self.addOutput(OutputFile(self.DROP_ANALYSIS_FILE, + self.tr('D-Infinity Drop to Stream Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-ad8') + commands.append(self.getParameterValue(self.D8_CONTRIB_AREA_GRID)) + commands.append('-p') + commands.append(self.getParameterValue(self.D8_FLOW_DIR_GRID)) + commands.append('-fel') + commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) + commands.append('-ssa') + commands.append(self.getParameterValue(self.ACCUM_STREAM_SOURCE_GRID)) + commands.append('-o') + commands.append(self.getParameterValue(self.OUTLETS_SHAPE)) + commands.append('-par') + commands.append(str(self.getParameterValue(self.MIN_TRESHOLD))) + commands.append(str(self.getParameterValue(self.MAX_THRESHOLD))) + commands.append(str(self.getParameterValue(self.TRESHOLD_NUM))) + commands.append(str(self.getParameterValue(self.STEPS))) + commands.append('-drp') + commands.append(self.getOutputValue(self.DROP_ANALYSIS_FILE)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/gridnet_multi.py b/python/plugins/processing/algs/taudem/gridnet_multi.py new file mode 100644 index 000000000000..6397073d0bbf --- /dev/null +++ b/python/plugins/processing/algs/taudem/gridnet_multi.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + gridnet_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterVector +from processing.core.parameters import ParameterNumber +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class GridNetMulti(GeoAlgorithm): + + D8_FLOW_DIR_GRID = 'D8_FLOW_DIR_GRID' + OUTLETS_SHAPE = 'OUTLETS_SHAPE' + MASK_GRID = 'MASK_GRID' + THRESHOLD = 'THRESHOLD' + + LONGEST_LEN_GRID = 'LONGEST_LEN_GRID' + TOTAL_LEN_GRID = 'TOTAL_LEN_GRID' + STRAHLER_GRID = 'STRAHLER_GRID' + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'Grid Network (multifile)' + self.cmdName = 'gridnet' + self.group = 'Basic Grid Analysis tools' + + self.addParameter(ParameterFile(self.D8_FLOW_DIR_GRID, + self.tr('D8 Flow Direction Grid'), True, False)) + self.addParameter(ParameterVector(self.OUTLETS_SHAPE, + self.tr('Outlets Shapefile'), + [ParameterVector.VECTOR_TYPE_POINT], True)) + self.addParameter(ParameterFile(self.MASK_GRID, + self.tr('Mask Grid'), True, True)) + self.addParameter(ParameterNumber(self.THRESHOLD, + self.tr('Mask Threshold'), 0, None, 100)) + + self.addOutput(OutputDirectory(self.LONGEST_LEN_GRID, + self.tr('Longest Upslope Length Grid'))) + self.addOutput(OutputDirectory(self.TOTAL_LEN_GRID, + self.tr('Total Upslope Length Grid'))) + self.addOutput(OutputDirectory(self.STRAHLER_GRID, + self.tr('Strahler Network Order Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-p') + commands.append(self.getParameterValue(self.D8_FLOW_DIR_GRID)) + param = self.getParameterValue(self.OUTLETS_SHAPE) + if param is not None: + commands.append('-o') + commands.append(param) + param = self.getParameterValue(self.MASK_GRID) + if param is not None: + commands.append('-mask') + commands.append(param) + commands.append('-thresh') + commands.append(self.getParameterValue(self.THRESHOLD)) + + commands.append('-plen') + commands.append(self.getOutputValue(self.LONGEST_LEN_GRID)) + commands.append('-tlen') + commands.append(self.getOutputValue(self.TOTAL_LEN_GRID)) + commands.append('-gord') + commands.append(self.getOutputValue(self.STRAHLER_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/lengtharea_multi.py b/python/plugins/processing/algs/taudem/lengtharea_multi.py new file mode 100644 index 000000000000..b8d53c83f26e --- /dev/null +++ b/python/plugins/processing/algs/taudem/lengtharea_multi.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + lengtharea_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterNumber +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class LengthAreaMulti(GeoAlgorithm): + + LENGTH_GRID = 'LENGTH_GRID' + CONTRIB_AREA_GRID = 'CONTRIB_AREA_GRID' + THRESHOLD = 'THRESHOLD' + EXPONENT = 'EXPONENT' + + STREAM_SOURCE_GRID = 'STREAM_SOURCE_GRID' + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'Length Area Stream Source (multifile)' + self.cmdName = 'lengtharea' + self.group = 'Stream Network Analysis tools' + + self.addParameter(ParameterFile(self.LENGTH_GRID, + self.tr('Length Grid'), True, False)) + self.addParameter(ParameterFile(self.CONTRIB_AREA_GRID, + self.tr('Contributing Area Grid'), True, False)) + self.addParameter(ParameterNumber(self.THRESHOLD, + self.tr('Threshold'), 0, None, 0.03)) + self.addParameter(ParameterNumber(self.EXPONENT, + self.tr('Exponent'), 0, None, 1.3)) + + self.addOutput(OutputDirectory(self.STREAM_SOURCE_GRID, + self.tr('Stream Source Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-plen') + commands.append(self.getParameterValue(self.LENGTH_GRID)) + commands.append('-ad8') + commands.append(self.getParameterValue(self.CONTRIB_AREA_GRID)) + commands.append('-par') + commands.append(str(self.getParameterValue(self.THRESHOLD))) + commands.append(str(self.getParameterValue(self.EXPONENT))) + commands.append('-ss') + commands.append(self.getOutputValue(self.STREAM_SOURCE_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/peukerdouglas_multi.py b/python/plugins/processing/algs/taudem/peukerdouglas_multi.py new file mode 100644 index 000000000000..5ed60e25d428 --- /dev/null +++ b/python/plugins/processing/algs/taudem/peukerdouglas_multi.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + peukerdouglas_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterNumber +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class PeukerDouglasMulti(GeoAlgorithm): + + ELEVATION_GRID = 'ELEVATION_GRID' + CENTER_WEIGHT = 'CENTER_WEIGHT' + SIDE_WEIGHT = 'SIDE_WEIGHT' + DIAGONAL_WEIGHT = 'DIAGONAL_WEIGHT' + + STREAM_SOURCE_GRID = 'STREAM_SOURCE_GRID' + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'Peuker Douglas (multifile)' + self.cmdName = 'peukerdouglas' + self.group = 'Stream Network Analysis tools' + + self.addParameter(ParameterFile(self.ELEVATION_GRID, + self.tr('Elevation Grid'), True, False)) + self.addParameter(ParameterNumber(self.CENTER_WEIGHT, + self.tr('Center Smoothing Weight'), 0, None, 0.4)) + self.addParameter(ParameterNumber(self.SIDE_WEIGHT, + self.tr('Side Smoothing Weight'), 0, None, 0.1)) + self.addParameter(ParameterNumber(self.DIAGONAL_WEIGHT, + self.tr('Diagonal Smoothing Weight'), 0, None, 0.05)) + + self.addOutput(OutputDirectory(self.STREAM_SOURCE_GRID, + self.tr('Stream Source Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-fel') + commands.append(self.getParameterValue(self.ELEVATION_GRID)) + commands.append('-par') + commands.append(str(self.getParameterValue(self.CENTER_WEIGHT))) + commands.append(str(self.getParameterValue(self.SIDE_WEIGHT))) + commands.append(str(self.getParameterValue(self.DIAGONAL_WEIGHT))) + commands.append('-ss') + commands.append(self.getOutputValue(self.STREAM_SOURCE_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress) diff --git a/python/plugins/processing/algs/taudem/slopearea_multi.py b/python/plugins/processing/algs/taudem/slopearea_multi.py new file mode 100644 index 000000000000..71398783b1bf --- /dev/null +++ b/python/plugins/processing/algs/taudem/slopearea_multi.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + slopearea_multi.py + --------------------- + Date : March 2015 + Copyright : (C) 2015 by Alexander Bruy + Email : alexander dot bruy at gmail dot com +*************************************************************************** +* * +* 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__ = 'Alexander Bruy' +__date__ = 'March 2015' +__copyright__ = '(C) 2015, Alexander Bruy' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +import os + +from PyQt4.QtGui import QIcon + +from processing.core.GeoAlgorithm import GeoAlgorithm +from processing.core.ProcessingConfig import ProcessingConfig +from processing.core.GeoAlgorithmExecutionException import \ + GeoAlgorithmExecutionException + +from processing.core.parameters import ParameterFile +from processing.core.parameters import ParameterNumber +from processing.core.outputs import OutputDirectory + +from TauDEMUtils import TauDEMUtils + + +class SlopeAreaMulti(GeoAlgorithm): + + SLOPE_GRID = 'SLOPE_GRID' + AREA_GRID = 'AREA_GRID' + SLOPE_EXPONENT = 'SLOPE_EXPONENT' + AREA_EXPONENT = 'AREA_EXPONENT' + + SLOPE_AREA_GRID = 'SLOPE_AREA_GRID' + + def getIcon(self): + return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png') + + def defineCharacteristics(self): + self.name = 'Slope Area Combination (multifile)' + self.cmdName = 'slopearea' + self.group = 'Stream Network Analysis tools' + + self.addParameter(ParameterFile(self.SLOPE_GRID, + self.tr('Slope Grid'), True, False)) + self.addParameter(ParameterFile(self.AREA_GRID, + self.tr('Contributing Area Grid'), True, False)) + self.addParameter(ParameterNumber(self.SLOPE_EXPONENT, + self.tr('Slope Exponent'), 0, None, 2)) + self.addParameter(ParameterNumber(self.AREA_EXPONENT, + self.tr('Area Exponent'), 0, None, 1)) + + self.addOutput(OutputDirectory(self.SLOPE_AREA_GRID, + self.tr('Slope Area Grid'))) + + def processAlgorithm(self, progress): + commands = [] + commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec')) + + processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES) + if processNum <= 0: + raise GeoAlgorithmExecutionException( + self.tr('Wrong number of MPI processes used. Please set ' + 'correct number before running TauDEM algorithms.')) + + commands.append('-n') + commands.append(str(processNum)) + commands.append(os.path.join(TauDEMUtils.taudemMultifilePath(), self.cmdName)) + commands.append('-slp') + commands.append(self.getParameterValue(self.SLOPE_GRID)) + commands.append('-sca') + commands.append(self.getParameterValue(self.AREA_GRID)) + commands.append('-par') + commands.append(str(self.getParameterValue(self.SLOPE_EXPONENT))) + commands.append(str(self.getParameterValue(self.AREA_EXPONENT))) + commands.append('-sa') + commands.append(self.getOutputValue(self.SLOPE_AREA_GRID)) + + TauDEMUtils.executeTauDEM(commands, progress)