mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[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)
This commit is contained in:
parent
30c5bad91d
commit
427adf79bb
@ -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})
|
||||
|
@ -27,18 +27,21 @@ __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 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
|
||||
|
||||
|
||||
|
@ -30,11 +30,13 @@ import os
|
||||
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 gridnet import GridNet
|
||||
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 @@ class TauDEMAlgorithmProvider(AlgorithmProvider):
|
||||
|
||||
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 @@ class TauDEMAlgorithmProvider(AlgorithmProvider):
|
||||
|
||||
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
|
||||
self.algs = []
|
||||
basePath = TauDEMUtils.taudemDescriptionPath()
|
||||
|
||||
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))
|
||||
if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_SINGLEFILE):
|
||||
folder = os.path.join(basePath, 'single')
|
||||
|
||||
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())
|
||||
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))))
|
||||
|
@ -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)
|
@ -26,18 +26,22 @@ __copyright__ = '(C) 2012, Alexander Bruy'
|
||||
__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 @@ class TauDEMUtils:
|
||||
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 @@ class TauDEMUtils:
|
||||
|
||||
@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):
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -0,0 +1,5 @@
|
||||
Pit Remove (multifile)
|
||||
pitremove
|
||||
Basic Grid Analysis tools
|
||||
ParameterFile|-z|Elevation Grid|True|False
|
||||
OutputDirectory|-fel|Pit Removed Elevation Grid
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
127
python/plugins/processing/algs/taudem/dinfdistdown_multi.py
Normal file
127
python/plugins/processing/algs/taudem/dinfdistdown_multi.py
Normal file
@ -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)
|
124
python/plugins/processing/algs/taudem/dinfdistup_multi.py
Normal file
124
python/plugins/processing/algs/taudem/dinfdistup_multi.py
Normal file
@ -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)
|
@ -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)
|
114
python/plugins/processing/algs/taudem/dinftranslimaccum_multi.py
Normal file
114
python/plugins/processing/algs/taudem/dinftranslimaccum_multi.py
Normal file
@ -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)
|
124
python/plugins/processing/algs/taudem/dropanalysis_multi.py
Normal file
124
python/plugins/processing/algs/taudem/dropanalysis_multi.py
Normal file
@ -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)
|
114
python/plugins/processing/algs/taudem/gridnet_multi.py
Normal file
114
python/plugins/processing/algs/taudem/gridnet_multi.py
Normal file
@ -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)
|
96
python/plugins/processing/algs/taudem/lengtharea_multi.py
Normal file
96
python/plugins/processing/algs/taudem/lengtharea_multi.py
Normal file
@ -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)
|
94
python/plugins/processing/algs/taudem/peukerdouglas_multi.py
Normal file
94
python/plugins/processing/algs/taudem/peukerdouglas_multi.py
Normal file
@ -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)
|
96
python/plugins/processing/algs/taudem/slopearea_multi.py
Normal file
96
python/plugins/processing/algs/taudem/slopearea_multi.py
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user