Skip to content
Permalink
Browse files

[sextante] fix parameters handling in some GDAL algorithms

  • Loading branch information
alexbruy committed Apr 10, 2013
1 parent dc15292 commit dc0d240dc9168321394ef8281f34f057ca1cae93
@@ -56,7 +56,7 @@ def processAlgorithm(self, progress):
arguments = []
inFile = self.getParameterValue(gdaladdo.INPUT)
arguments.append(inFile)
arguments.append(self.getParameterValue(gdaladdo.LEVELS))
arguments.extend(self.getParameterValue(gdaladdo.LEVELS).split(" "))
self.setOutputValue(gdaladdo.OUTPUT, inFile)

GdalUtils.runGdal(["gdaladdo", GdalUtils.escapeAndJoin(arguments)], progress)
@@ -68,11 +68,10 @@ def defineCharacteristics(self):
self.addParameter(ParameterCrs(translate.SRS, "Override the projection for the output file", None))
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.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))
@@ -87,20 +86,31 @@ def processAlgorithm(self, progress):
arguments.append("-of")
arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
if outsizePerc == "True":
outsizeStr = "-outsize " + outsize + "% " + outsize + "%"
arguments.append("-outsize")
arguments.append(outsize + "%")
arguments.append(outsize + "%")
else:
outsizeStr = "-outsize " + outsize + " " + outsize
arguments.append(outsizeStr)
arguments.append("-a_nodata " + noData)
arguments.append("-outsize")
arguments.append(outsize)
arguments.append(outsize)
arguments.append("-a_nodata")
arguments.append(noData)
if expand != "none":
arguments.append("-expand " + expand)
arguments.append("-expand")
arguments.append(expand)
regionCoords = projwin.split(",")
arguments.append("-projwin " + regionCoords[0] + " " + regionCoords[3] + " " + regionCoords[1] + " " + regionCoords[2])
arguments.append("-projwin")
arguments.append(regionCoords[0])
arguments.append(regionCoords[3])
arguments.append(regionCoords[1])
arguments.append(regionCoords[2])
if srs is not None:
arguments.append("-a_srs " + str(srs))
arguments.append("-a_srs")
arguments.append(str(srs))
if sds:
arguments.append("-sds")
arguments.append(extra)
if len(extra) > 0:
arguments.append(extra)
arguments.append(self.getParameterValue(translate.INPUT))
arguments.append(out)

@@ -62,26 +62,27 @@ def defineCharacteristics(self):
self.addParameter(ParameterCrs(warp.DEST_SRS, "Destination SRS (EPSG Code)", "EPSG:4326"))
self.addParameter(ParameterNumber(warp.TR, "Output file resolution in target georeferenced units (leave 0 for no change)", 0.0, None, 0.0))
self.addParameter(ParameterSelection(warp.METHOD, "Resampling method", warp.METHOD_OPTIONS))
self.addParameter(ParameterString(warp.EXTRA, "Additional creation parameters", " "))
self.addParameter(ParameterString(warp.EXTRA, "Additional creation parameters", ""))
self.addOutput(OutputRaster(warp.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
srs = self.getParameterValue(warp.DEST_SRS)
self.crs = QgsCoordinateReferenceSystem(srs)
arguments = []
arguments.append("-s_srs")
arguments.append(str(self.getParameterValue(warp.SOURCE_SRS)))
arguments.append("-t_srs")
arguments.append(str(srs))
arguments.append(str(self.getParameterValue(warp.DEST_SRS)))
arguments.append("-r")
arguments.append(warp.METHOD_OPTIONS[self.getParameterValue(warp.METHOD)])
arguments.append("-of")
out = self.getOutputValue(warp.OUTPUT)
arguments.append(GdalUtils.getFormatShortNameFromFilename(out))
if self.getParameterValue(warp.TR) != 0:
trStr = "-tr " + str(self.getParameterValue(warp.TR)) + " " + str(self.getParameterValue(warp.TR))
arguments.append(trStr)
arguments.append(str(self.getParameterValue(warp.EXTRA)))
arguments.append("-tr")
arguments.append(str(self.getParameterValue(warp.TR)))
arguments.append(str(self.getParameterValue(warp.TR)))
extra = str(self.getParameterValue(warp.EXTRA))
if len(extra) > 0:
arguments.append(extra)
arguments.append(self.getParameterValue(warp.INPUT))
arguments.append(out)

0 comments on commit dc0d240

Please sign in to comment.
You can’t perform that action at this time.