Skip to content

Commit

Permalink
Several patches contributed by Rado Guzinski:
Browse files Browse the repository at this point in the history
-New OTB descriptions an help
-Update OTB descriptions
-More responsive MultipleInputPanel.py
-Minor bug fixes
  • Loading branch information
volaya committed Oct 17, 2012
1 parent 5afd739 commit c4c3fec
Show file tree
Hide file tree
Showing 82 changed files with 11,720 additions and 36 deletions.
3 changes: 3 additions & 0 deletions python/plugins/sextante/core/Sextante.py
Expand Up @@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -25,6 +26,7 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.wps.WPSAlgorithmProvider import WPSAlgorithmProvider
from sextante.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
from sextante.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider
from sextante.core.QGisLayers import QGisLayers
Expand Down Expand Up @@ -121,6 +123,7 @@ def initialize():
Sextante.addProvider(SagaAlgorithmProvider())
Sextante.addProvider(GrassAlgorithmProvider())
Sextante.addProvider(ScriptAlgorithmProvider())
Sextante.addProvider(WPSAlgorithmProvider())
Sextante.modeler.initializeSettings();
#and initialize
SextanteLog.startLogging()
Expand Down
1 change: 1 addition & 0 deletions python/plugins/sextante/gdal/warp.py
Expand Up @@ -31,6 +31,7 @@
from qgis.core import *
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.gdal.GdalUtils import GdalUtils

class warp(GeoAlgorithm):

Expand Down
29 changes: 27 additions & 2 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Expand Up @@ -129,9 +129,31 @@ def defineCharacteristicsFromFile(self):
lines.close()

self.addParameter(ParameterExtent(self.GRASS_REGION_EXTENT_PARAMETER, "GRASS region extent"))
self.addParameter(ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER, "GRASS region cellsize", 0, None, 1))
self.addParameter(ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER, "GRASS region cellsize (leave 0 for default)", 0, None, 0.0))


def getDefaultCellsize(self):
cellsize = 0
for param in self.parameters:
if param.value:
if isinstance(param, ParameterRaster):
if isinstance(param.value, QgsRasterLayer):
layer = param.value
else:
layer = QGisLayers.getObjectFromUri(param.value)
cellsize = max(cellsize, (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width())

elif isinstance(param, ParameterMultipleInput):
layers = param.value.split(";")
for layername in layers:
layer = QGisLayers.getObjectFromUri(layername)
if isinstance(layer, QgsRasterLayer):
cellsize = max(cellsize, (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width())

if cellsize == 0:
cellsize = 1
return cellsize

def processAlgorithm(self, progress):
if SextanteUtils.isWindows():
path = GrassUtils.grassPath()
Expand All @@ -151,7 +173,10 @@ def processAlgorithm(self, progress):
command +=" s=" + str(regionCoords[2])
command +=" e=" + str(regionCoords[1])
command +=" w=" + str(regionCoords[0])
command +=" res=" + str(self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER));
if self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER) == 0:
command +=" res=" + str(self.getDefaultCellsize())
else:
command +=" res=" + str(self.getParameterValue(self.GRASS_REGION_CELLSIZE_PARAMETER));
commands.append(command)

#1: Export layer to grass mapset
Expand Down
10 changes: 10 additions & 0 deletions python/plugins/sextante/grass/description/r.series.txt
@@ -0,0 +1,10 @@
r.series
r.series - Makes each output cell value a function of the values assigned to the corresponding cells in the input raster map layers.
Raster (r.*)
ParameterMultipleInput|input|Name of input raster map(s)|3.0|False
ParameterBoolean|-n|Propagate NULLs|True
ParameterSelection|method|Aggregate operation|average;count;median;mode;minimum;min_raster;maximum;max_raster;stddev;range;sum;threshold;variance;diversity;slope;offset;detcoeff;quart1;quart3;perc90;quantile;skewness;kurtosis
ParameterNumber|quantile|Quantile to calculate for method=quantile|0.0|1.0|0.0
ParameterNumber|threshold|Threshold to calculate for method=threshold|None|None|0.0
ParameterString|range|Ignore values outside this range (lo,hi)|-10000000000,10000000000
OutputRaster|output|Name for output raster map
19 changes: 16 additions & 3 deletions python/plugins/sextante/gui/BatchProcessingDialog.py
Expand Up @@ -32,6 +32,12 @@
from sextante.gui.BatchInputSelectionPanel import BatchInputSelectionPanel
from sextante.gui.AlgorithmExecutionDialog import AlgorithmExecutionDialog

from sextante.parameters.ParameterExtent import ParameterExtent
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterFile import ParameterFile
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.gui.ExtentSelectionPanel import ExtentSelectionPanel

from sextante.parameters.ParameterBoolean import ParameterBoolean
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.parameters.ParameterFixedTable import ParameterFixedTable
Expand All @@ -52,7 +58,8 @@ def __init__(self, alg):
self.algs = None
self.table = QtGui.QTableWidget(None)
AlgorithmExecutionDialog.__init__(self, alg, self.table)
self.setModal(True)
#self.setModal(True)
self.setWindowModality(1)
self.algEx = None
self.resize(800, 500)
self.setWindowTitle("Batch Processing - " + self.alg.name)
Expand Down Expand Up @@ -93,7 +100,7 @@ def accept(self):
col = 0
for param in alg.parameters:
widget = self.table.cellWidget(row, col)
if not self.setParameterValueFromWidget(param, widget):
if not self.setParameterValueFromWidget(param, widget, alg):
QMessageBox.critical(self.dialog, "Unable to execute batch process", "Wrong or missing parameter values")
self.algs = None
return
Expand Down Expand Up @@ -176,7 +183,7 @@ def finishAll(self):
QMessageBox.information(self, "Batch processing", "Batch processing successfully completed!")
self.close()

def setParameterValueFromWidget(self, param, widget):
def setParameterValueFromWidget(self, param, widget, alg = None):
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable, ParameterMultipleInput)):
return param.setValue(widget.getText())
elif isinstance(param, ParameterBoolean):
Expand All @@ -185,6 +192,10 @@ def setParameterValueFromWidget(self, param, widget):
return param.setValue(widget.currentIndex())
elif isinstance(param, ParameterFixedTable):
return param.setValue(widget.table)
elif isinstance(param, (ParameterExtent)):
if alg != None:
widget.useNewAlg(alg)
return param.setValue(widget.getValue())
else:
return param.setValue(widget.text())

Expand All @@ -204,6 +215,8 @@ def getWidgetFromParameter(self, param, row, col):
item.addItems(param.options)
elif isinstance(param, ParameterFixedTable):
item = FixedTablePanel(param)
elif isinstance(param, ParameterExtent):
item = ExtentSelectionPanel(self, self.alg, param.default)
else:
item = QtGui.QLineEdit()
try:
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/sextante/gui/ExtentSelectionPanel.py
Expand Up @@ -112,7 +112,8 @@ def getMinCoveringExtent(self):
else:
return None


def useNewAlg(self, alg):
self.params = alg.parameters

def addToRegion(self, layer, first):
if first:
Expand Down
16 changes: 15 additions & 1 deletion python/plugins/sextante/gui/MultipleInputPanel.py
Expand Up @@ -25,6 +25,8 @@

from PyQt4 import QtCore, QtGui
from sextante.gui.MultipleInputDialog import MultipleInputDialog
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput
from sextante.core.QGisLayers import QGisLayers

try:
_fromUtf8 = QtCore.QString.fromUtf8
Expand All @@ -33,9 +35,10 @@

class MultipleInputPanel(QtGui.QWidget):

def __init__(self, options, parent = None):
def __init__(self, options, datatype, parent = None):
super(MultipleInputPanel, self).__init__(parent)
self.options = options
self.datatype = datatype
self.selectedoptions = []
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2)
Expand All @@ -51,6 +54,17 @@ def __init__(self, options, parent = None):
self.setLayout(self.horizontalLayout)

def showSelectionDialog(self):
if self.datatype == ParameterMultipleInput.TYPE_RASTER:
options = QGisLayers.getRasterLayers()
elif self.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = QGisLayers.getVectorLayers()
else:
options = QGisLayers.getVectorLayers(self.datatype)
opts = []
for opt in options:
opts.append(opt.name())
self.options = opts

dlg = MultipleInputDialog(self.options, self.selectedoptions)
dlg.exec_()
if dlg.selectedoptions != None:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/ParametersPanel.py
Expand Up @@ -276,7 +276,7 @@ def getWidgetFromParameter(self, param):
opts = []
for opt in options:
opts.append(opt.name())
item = MultipleInputPanel(opts)
item = MultipleInputPanel(opts, param.datatype)
elif isinstance(param, ParameterNumber):
item = NumberInputPanel(param.default, param.isInteger)
elif isinstance(param, ParameterExtent):
Expand Down
13 changes: 12 additions & 1 deletion python/plugins/sextante/modeler/ModelerParametersDialog.py
Expand Up @@ -119,7 +119,7 @@ def setupUi(self):
for output in self.alg.outputs:
if output.hidden:
continue
if isinstance(output, (OutputRaster, OutputVector, OutputTable, OutputHTML)):
if isinstance(output, (OutputRaster, OutputVector, OutputTable, OutputHTML, OutputFile)):
label = QtGui.QLabel(output.description + "<" + output.__module__.split(".")[-1] + ">")
item = QLineEdit()
if hasattr(item, 'setPlaceholderText'):
Expand Down Expand Up @@ -170,6 +170,17 @@ def setupUi(self):
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.cancelPressed)
QtCore.QMetaObject.connectSlotsByName(self)

def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced
if self.showAdvanced:
self.advancedButton.setText("Hide advanced parameters")
else:
self.advancedButton.setText("Show advanced parameters")
for param in self.alg.parameters:
if param.isAdvanced:
self.labels[param.name].setVisible(self.showAdvanced)
self.widgets[param.name].setVisible(self.showAdvanced)

def getRasterLayers(self):
layers = []
params = self.model.parameters
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/sextante/otb/OTBAlgorithm.py
Expand Up @@ -38,6 +38,7 @@
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.SextanteLog import SextanteLog
from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.WrongHelpFileException import WrongHelpFileException
from sextante.parameters.ParameterFactory import ParameterFactory
from sextante.outputs.OutputFactory import OutputFactory
from sextante.otb.OTBUtils import OTBUtils
Expand Down Expand Up @@ -65,10 +66,11 @@ def getIcon(self):

def helpFile(self):
folder = os.path.join( OTBUtils.otbDescriptionPath(), 'doc' )
if str(folder).strip() != "":
helpfile = os.path.join( str(folder), self.appkey + ".html")
helpfile = os.path.join( str(folder), self.appkey + ".html")
if os.path.exists(helpfile):
return helpfile
return None
else:
raise WrongHelpFileException("Could not find help file for this algorithm. \nIf you have it put it in: \n"+str(folder))

def defineCharacteristicsFromFile(self):
lines = open(self.descriptionFile)
Expand Down
33 changes: 33 additions & 0 deletions python/plugins/sextante/otb/description/BlockMatching.txt
@@ -0,0 +1,33 @@
BlockMatching
otbcli_BlockMatching
Pixel-wise Block-Matching
Stereo
ParameterRaster|-io.inleft|Left input image|False
ParameterRaster|-io.inright|Right input image|False
OutputRaster|-io.out|The output disparity map
OutputRaster|-io.outmask|The output mask corresponding to all criterions
ParameterBoolean|-io.outmetric|Output optimal metric values as well|
ParameterRaster|-mask.inleft|Discard left pixels from mask image|True
ParameterRaster|-mask.inright|Discard right pixels from mask image|True
ParameterNumber|-mask.nodata|Discard pixels with no-data value|None|None|0.0
ParameterNumber|-mask.variancet|Discard pixels with low local variance|None|None|100.0
ParameterSelection|-bm.metric|Block-matching metric|ssd;ncc;lp|0
ParameterNumber|-bm.metric.lp.p|p value|None|None|1.0
ParameterNumber|-bm.radius|Radius of blocks|None|None|3
ParameterNumber|-bm.minhd|Minimum horizontal disparity|None|None|0
ParameterNumber|-bm.maxhd|Maximum horizontal disparity|None|None|0
ParameterNumber|-bm.minvd|Minimum vertical disparity|None|None|0
ParameterNumber|-bm.maxvd|Maximum vertical disparity|None|None|0
ParameterSelection|-bm.subpixel|Sub-pixel interpolation|none;parabolic;triangular;dichotomy|0
ParameterNumber|-bm.medianfilter.radius|Radius|None|None|0
ParameterNumber|-bm.medianfilter.incoherence|Incoherence threshold|None|None|0.0
ParameterSelection|-bm.initdisp|Initial disparities|none;uniform;maps|0
ParameterNumber|-bm.initdisp.uniform.hdisp|Horizontal initial disparity|None|None|0
ParameterNumber|-bm.initdisp.uniform.vdisp|Vertical initial disparity|None|None|0
ParameterNumber|-bm.initdisp.uniform.hrad|Horizontal exploration radius|None|None|0
ParameterNumber|-bm.initdisp.uniform.vrad|Vertical exploration radius|None|None|0
ParameterRaster|-bm.initdisp.maps.hmap|Horizontal initial disparity map|False
ParameterRaster|-bm.initdisp.maps.vmap|Vertical initial disparity map|False
ParameterNumber|-bm.initdisp.maps.hrad|Horizontal exploration radius|None|None|0
ParameterNumber|-bm.initdisp.maps.vrad|Vertical exploration radius|None|None|0
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
2 changes: 1 addition & 1 deletion python/plugins/sextante/otb/description/ColorMapping.txt
@@ -1,7 +1,7 @@
ColorMapping
otbcli_ColorMapping
Color Mapping
Learning
Image Manipulation
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
Expand Down
Expand Up @@ -4,12 +4,9 @@ Cartographic to geographic coordinates conversion
Geometry
ParameterNumber|-carto.x|X cartographic coordinates|None|None|0.0
ParameterNumber|-carto.y|Y cartographic coordinates|None|None|0.0
ParameterSelection|-mapproj|Output Cartographic Map Projection|utm;lambert2;lambert93;transmercator;wgs;epsg|5
ParameterNumber|-mapproj.utm.zone|Zone number|None|None|0
ParameterSelection|-mapproj|Output Cartographic Map Projection|utm;lambert2;lambert93;wgs;epsg|4
ParameterNumber|-mapproj.utm.zone|Zone number|None|None|31
ParameterBoolean|-mapproj.utm.northhem|Northern Hemisphere|
ParameterNumber|-mapproj.transmercator.falseeasting|False easting|None|None|0.0
ParameterNumber|-mapproj.transmercator.falsenorthing|False northing|None|None|0.0
ParameterNumber|-mapproj.transmercator.scale|Scale factor|None|None|1.0
ParameterNumber|-mapproj.epsg.code|EPSG Code|None|None|32631
ParameterNumber|-long|Output long|None|None|0.0
ParameterNumber|-lat|Output lat|None|None|0.0
@@ -0,0 +1,16 @@
DimensionalityReduction
otbcli_DimensionalityReduction
Dimensionality reduction application
Image Filtering
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-rescale.outmin|Output min value|None|None|0.0
ParameterNumber|-rescale.outmax|Output max value|None|None|255.0
OutputRaster|-outinv| Inverse Output Image
ParameterSelection|-method|Algorithm|pca;napca;maf;ica|0
ParameterNumber|-method.napca.radiusx|Set the x radius of the sliding window.|None|None|1
ParameterNumber|-method.napca.radiusy|Set the y radius of the sliding window.|None|None|1
ParameterNumber|-method.ica.iter|number of iterations |None|None|20
ParameterNumber|-method.ica.mu|Give the increment weight of W in [0, 1]|None|None|1.0
ParameterNumber|-nbcomp|Number of Components.|None|None|0
ParameterBoolean|-normalize|Normalize.|
@@ -0,0 +1,19 @@
DisparityMapToElevationMap
otbcli_DisparityMapToElevationMap
Disparity map to elevation map
Stereo
ParameterRaster|-io.in|Input disparity map|False
ParameterRaster|-io.left|Left sensor image|False
ParameterRaster|-io.right|Right sensor image|False
ParameterRaster|-io.lgrid|Left Grid|False
ParameterRaster|-io.rgrid|Right Grid|False
OutputRaster|-io.out|Output elevation map
ParameterRaster|-io.mask|Disparity mask|True
ParameterNumber|-step|DEM step|None|None|5.0
ParameterNumber|-hmin|Minimum elevation expected|None|None|0.0
ParameterNumber|-hmax|Maximum elevation expected|None|None|100.0
ParameterSelection|-elev|Elevation management|dem;average|1
ParameterFile|-elev.dem.path|DEM directory|
ParameterFile|-elev.dem.geoid|Geoid File||
ParameterNumber|-elev.average.value|Average Elevation|None|None|0.0
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
1 change: 1 addition & 0 deletions python/plugins/sextante/otb/description/ImageEnvelope.txt
Expand Up @@ -4,6 +4,7 @@ Image Envelope
Geometry
ParameterRaster|-in|Input Image|False
OutputVector|-out|Output Vector Data
ParameterNumber|-sr|Sampling Rate|None|None|0
ParameterSelection|-elev|Elevation management|dem;average|1
ParameterFile|-elev.dem.path|DEM directory|
ParameterFile|-elev.dem.geoid|Geoid File||
Expand Down
11 changes: 11 additions & 0 deletions python/plugins/sextante/otb/description/MeanShiftSmoothing.txt
@@ -0,0 +1,11 @@
MeanShiftSmoothing
otbcli_MeanShiftSmoothing
Mean Shift filtering
Image Filtering
ParameterRaster|-in|Input Image|False
OutputRaster|-fout|Filtered output
ParameterNumber|-spatialr|Spatial radius|None|None|5
ParameterNumber|-ranger|Range radius|None|None|15.0
ParameterNumber|-thres|Mode convergence threshold|None|None|0.10000000149
ParameterNumber|-maxiter|Maximum number of iterations|None|None|100
ParameterBoolean|-modesearch|Mode search.|True
Expand Up @@ -14,3 +14,4 @@ ParameterNumber|-atmo.wa|Water Vapor Amount|None|None|2.5
ParameterNumber|-atmo.pressure|Atmospheric Pressure|None|None|1030.0
ParameterNumber|-atmo.opt|Aerosol Optical Thickness|None|None|0.20000000298
ParameterFile|-atmo.aeronet|Aeronet File||
ParameterNumber|-radius|Window radius|None|None|2
Expand Up @@ -4,12 +4,9 @@ Ortho-rectification
Geometry
ParameterRaster|-io.in|Input Image|False
OutputRaster|-io.out|Output Image
ParameterSelection|-map|Output Cartographic Map Projection|utm;lambert2;lambert93;transmercator;wgs;epsg|5
ParameterNumber|-map.utm.zone|Zone number|None|None|0
ParameterSelection|-map|Output Cartographic Map Projection|utm;lambert2;lambert93;wgs;epsg|4
ParameterNumber|-map.utm.zone|Zone number|None|None|31
ParameterBoolean|-map.utm.northhem|Northern Hemisphere|
ParameterNumber|-map.transmercator.falseeasting|False easting|None|None|0.0
ParameterNumber|-map.transmercator.falsenorthing|False northing|None|None|0.0
ParameterNumber|-map.transmercator.scale|Scale factor|None|None|1.0
ParameterNumber|-map.epsg.code|EPSG Code|None|None|32631
ParameterSelection|-outputs.mode|Parameters estimation modes|auto;autosize;autospacing|0
ParameterNumber|-outputs.ulx|Upper Left X|None|None|0.0
Expand Down

1 comment on commit c4c3fec

@slarosa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Victor, wps module seems missing. Just compiled I get error:
ImportError: No module named wps.WPSAlgorithmProvider

Please sign in to comment.