Skip to content

Commit

Permalink
minor fixes for otb and gdal, and edited some grass descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Dec 21, 2012
1 parent b54e905 commit c873e29
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 44 deletions.
46 changes: 44 additions & 2 deletions python/plugins/sextante/gdal/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
from PyQt4 import QtGui
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterBoolean import ParameterBoolean
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.parameters.ParameterExtent import ParameterExtent
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.outputs.OutputRaster import OutputRaster
import os
from sextante.gdal.GdalUtils import GdalUtils
Expand All @@ -35,6 +40,13 @@ class translate(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"
OUTSIZE = "OUTSIZE"
OUTSIZE_PERC = "OUTSIZE_PERC"
NO_DATA = "NO_DATA"
EXPAND = "EXPAND"
PROJWIN = "PROJWIN"
SRS = "SRS"
SDS = "SDS"
EXTRA = "EXTRA"

def getIcon(self):
Expand All @@ -45,15 +57,45 @@ def defineCharacteristics(self):
self.name = "Translate (convert format)"
self.group = "[GDAL] Conversion"
self.addParameter(ParameterRaster(translate.INPUT, "Input layer", False))
self.addParameter(ParameterNumber(translate.OUTSIZE, "Set the size of the output file (In pixels or %)", 1, None, 100))
self.addParameter(ParameterBoolean(translate.OUTSIZE_PERC, "Output size is a percentage of input size", True))
self.addParameter(ParameterString(translate.NO_DATA, "Nodata value, leave as none to take the nodata value from input", "none"))
self.addParameter(ParameterSelection(translate.EXPAND, "Expand", ["none","gray","rgb","rgba"]))
self.addParameter(ParameterCrs(translate.SRS, "Override the projection for the output file", ""))
self.addParameter(ParameterExtent(translate.PROJWIN, "Subset based on georeferenced coordinates"))
self.addParameter(ParameterBoolean(translate.SDS, "Copy all subdatasets of this file to individual output files", False))
self.addParameter(ParameterString(translate.EXTRA, "Additional creation parameters"))
self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):

out = self.getOutputValue(translate.OUTPUT)
outsize = str(self.getParameterValue(translate.OUTSIZE))
outsizePerc = str(self.getParameterValue(translate.OUTSIZE_PERC))
noData = str(self.getParameterValue(translate.NO_DATA))
expand = str(self.getParameterFromName(translate.EXPAND).options[self.getParameterValue(translate.EXPAND)])
projwin = str(self.getParameterValue(translate.PROJWIN))
srs = str(self.getParameterValue(translate.SRS))
sds = str(self.getParameterValue(translate.SDS))
extra = str(self.getParameterValue(translate.EXTRA))

commands = ["gdal_translate"]
commands.append("-of")
out = self.getOutputValue(translate.OUTPUT)
extra = self.getOutputValue(translate.EXTRA)
commands.append(GdalUtils.getFormatShortNameFromFilename(out))
if outsizePerc == "True":
outsizeStr = "-outsize "+outsize+"% "+outsize+"%"
else:
outsizeStr = "-outsize "+outsize+" "+outsize
commands.append(outsizeStr)
commands.append("-a_nodata "+noData)
if expand != "none":
commands.append("-expand "+expand)
regionCoords = projwin.split(",")
commands.append("-projwin "+regionCoords[0]+" "+regionCoords[3]+" "+regionCoords[1]+" "+regionCoords[2])
if srs != "":
commands.append("-a_srs EPSG:"+srs)
if sds == "True":
commands.append("-sds")
commands.append(extra)
commands.append(self.getParameterValue(translate.INPUT))
commands.append(out)
Expand Down
7 changes: 3 additions & 4 deletions python/plugins/sextante/grass/description/r.kappa.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
r.kappa
r.kappa - Calculate error matrix and kappa parameter for accuracy assessment of classification result.
Raster (r.*)
ParameterRaster|classification|Name of raster map containing classification result|False
ParameterRaster|reference|Name of raster map containing reference classes|False
ParameterRaster|classification|Raster layer containing classification result|False
ParameterRaster|reference|Raster layer containing reference classes|False
ParameterString|title|Title for error matrix and kappa|ACCURACY ASSESSMENT
ParameterBoolean|-w|Wide report 132 columns (default: 80)|False
ParameterBoolean|-h|No header in the report|False
OutputFile|output|Name for output file containing error matrix and kappa
OutputFile|output|output file containing error matrix and kappa
10 changes: 5 additions & 5 deletions python/plugins/sextante/grass/description/r.lake.coords.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
r.lake
r.lake.coords - Fills lake at given point to given level.
Raster (r.*)
ParameterRaster|dem|Name of terrain raster map (DEM)|False
ParameterString|wl|Water level|
ParameterString|xy|Seed point coordinates|
ParameterBoolean|-n|Use negative depth values for lake raster map|False
OutputRaster|lake|Name for output raster map with lake
ParameterRaster|dem|Elevation|False
ParameterNumber|wl|Water level|None|None|1000.0
ParameterString|xy|Seed point coordinates|0,0
ParameterBoolean|-n|Use negative depth values for lake raster layer|False
OutputRaster|lake|Raster map with lake
8 changes: 4 additions & 4 deletions python/plugins/sextante/grass/description/r.lake.layer.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
r.lake
r.lake.layer - Fills lake at given point to given level.
Raster (r.*)
ParameterRaster|dem|Name of terrain raster map (DEM)|False
ParameterString|wl|Water level|
ParameterRaster|dem|Elevation|False
ParameterNumber|wl|Water level|None|None|1000.0
ParameterRaster|seed|Name of raster map with given starting point(s) (at least 1 cell > 0)|False
ParameterBoolean|-n|Use negative depth values for lake raster map|False
OutputRaster|lake|Name for output raster map with lake
ParameterBoolean|-n|Use negative depth values for lake raster layer|False
OutputRaster|lake|Outtput raster map with lake
6 changes: 3 additions & 3 deletions python/plugins/sextante/grass/description/r.los.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
r.los
r.los - Line-of-sight raster analysis program.
Raster (r.*)
ParameterRaster|input|Name of elevation raster map|False
ParameterRaster|input|Elevation|False
ParameterString|coordinate|Coordinate identifying the viewing position|0,0
ParameterRaster|patt_map|Binary (1/0) raster map to use as a mask|True
ParameterRaster|patt_map|Binary (1/0) raster layer to use as a mask|True
ParameterString|obs_elev|Viewing position height above the ground|1.75
ParameterString|max_dist|Maximum distance from the viewing point (meters)|10000
ParameterBoolean|-c|Consider earth curvature (current ellipsoid)|False
OutputRaster|output|Name for output raster map
OutputRaster|output|Output raster layer
16 changes: 8 additions & 8 deletions python/plugins/sextante/grass/description/r.mapcalculator.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
r.mapcalculator
r.mapcalculator - Calculate new raster map from a r.mapcalc expression.
Raster (r.*)
ParameterRaster|amap|amap|False
ParameterRaster|bmap|bmap|True
ParameterRaster|cmap|cmap|True
ParameterRaster|dmap|dmap|True
ParameterRaster|emap|emap|True
ParameterRaster|fmap|fmap|True
ParameterString|formula|Formula (e.g. A-B or A*C+B)|
OutputRaster|outfile|Name for output raster map
ParameterRaster|amap|Raster layer A|False
ParameterRaster|bmap|Raster layer B|True
ParameterRaster|cmap|Raster layer C|True
ParameterRaster|dmap|Raster layer D|True
ParameterRaster|emap|Raster layer E|True
ParameterRaster|fmap|Raster layer F|True
ParameterString|formula|Formula| A*C+B
OutputRaster|outfile|Output raster layer
8 changes: 4 additions & 4 deletions python/plugins/sextante/grass/description/r.median.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r.median
r.median - Finds the median of values in a cover map within areas assigned the same category value in a user-specified base map.
r.median - Finds the median of values in a cover layer within areas assigned the same category value in a user-specified base layer.
Raster (r.*)
ParameterRaster|base|Name of base raster map|False
ParameterRaster|cover|Name of cover raster map|False
OutputRaster|output|Name for output raster map
ParameterRaster|base|Base raster layer|False
ParameterRaster|cover|Cover layer|False
OutputRaster|output|Output raster layer
14 changes: 8 additions & 6 deletions python/plugins/sextante/gui/ExtentSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@ def getMinCoveringExtent(self):
for param in self.params:
if param.value:
if isinstance(param, (ParameterRaster, ParameterVector)):
found = True
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
layer = param.value
else:
layer = QGisLayers.getObjectFromUri(param.value)
self.addToRegion(layer, first)
first = False
if layer:
found = True
self.addToRegion(layer, first)
first = False
elif isinstance(param, ParameterMultipleInput):
found = True
layers = param.value.split(";")
for layername in layers:
layer = QGisLayers.getObjectFromUri(layername, first)
self.addToRegion(layer, first)
first = False
if layer:
found = True
self.addToRegion(layer, first)
first = False
if found:
return str(self.xmin) + "," + str(self.xmax) + "," + str(self.ymin) + "," + str(self.ymax)
else:
Expand Down
4 changes: 4 additions & 0 deletions python/plugins/sextante/otb/OTBAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def defineCharacteristicsFromFile(self):
if param.name == "-elev.dem.geoid":
param.default = OTBUtils.otbGeoidPath()
self.addParameter(param)
elif line.startswith("*Parameter"):
param = ParameterFactory.getFromString(line[1:])
param.isAdvanced = True
self.addParameter(param)
elif line.startswith("Extent"):
self.addParameter(ParameterExtent(self.REGION_OF_INTEREST, "Region of interest", "0,1,0,1"))
self.hasROI = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Train SVM classifier from multiple images
Learning
ParameterMultipleInput|-io.il|Input Image List|3|False
ParameterMultipleInput|-io.vd|Vector Data List|-1|False
ParameterFile|-io.imstat|XML image statistics file||
ParameterFile|-io.imstat|XML image statistics file|
OutputFile|-io.out|Output SVM model
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|-sample.mt|Maximum training sample size|None|None|-1
ParameterNumber|-sample.mv|Maximum validation sample size|None|None|-1
ParameterBoolean|-sample.edg|On edge pixel inclusion|
*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|-sample.mt|Maximum training sample size|None|None|-1
*ParameterNumber|-sample.mv|Maximum validation sample size|None|None|-1
*ParameterBoolean|-sample.edg|On edge pixel inclusion|
ParameterNumber|-sample.vtr|training and validation sample ratio|None|None|0.5
ParameterString|-sample.vfn|Name of the discrimination field|Class
ParameterSelection|-svm.k|SVM Kernel Type|linear;rbf;poly;sigmoid|0
Expand Down

0 comments on commit c873e29

Please sign in to comment.