Skip to content
Permalink
Browse files

[processing] saga import/export optimization

  • Loading branch information
volaya committed Sep 15, 2013
1 parent 048c26a commit 788407accdb9a7232eec41d824d3d54015d64b1e
@@ -153,6 +153,8 @@ def calculateResamplingExtent(self):


def addToResamplingExtent(self, layer, first):
if layer is None:
return
if first:
self.inputExtentsCount = 1
self.xmin = layer.extent().xMinimum()
@@ -304,16 +306,30 @@ def processAlgorithm(self, progress):
commands.append(command)

#3:Export resulting raster layers
optim = ProcessingConfig.getSetting(SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION)
for out in self.outputs:
if isinstance(out, OutputRaster):
filename = out.getCompatibleFileName(self)
filename2 = filename + ".sgrd"
formatIndex = 1 if saga208 else 4
sessionExportedLayers[filename] = filename2
dontExport = True

#Do not export is the output is not a final output of the model
if self.model is not None and optim:
for subalg in self.model.algOutputs:
if out.name in subalg:
if subalg[out.name] is not None:
dontExport = False
break
if dontExport:
continue

if isWindows() or isMac() or not saga208:
commands.append("io_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT " + str(formatIndex) +" -TYPE 0 -FILE \"" + filename + "\"");
else:
commands.append("libio_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT 1 -TYPE 0 -FILE \"" + filename + "\"");
sessionExportedLayers[filename] = filename2



#4 Run SAGA
@@ -46,6 +46,7 @@ def initializeSettings(self):
if isWindows():
ProcessingConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_FOLDER, "SAGA folder", SagaUtils.sagaPath()))
ProcessingConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_208, "Enable SAGA 2.0.8 compatibility", False))
ProcessingConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION, "Enable SAGA Import/Export optimizations", False))
ProcessingConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_AUTO_RESAMPLING, "Use min covering grid system for resampling", True))
ProcessingConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_LOG_COMMANDS, "Log execution commands", True))
ProcessingConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_LOG_CONSOLE, "Log console output", True))
@@ -46,6 +46,8 @@ class SagaUtils:
SAGA_RESAMPLING_REGION_YMAX = "SAGA_RESAMPLING_REGION_YMAX"
SAGA_RESAMPLING_REGION_CELLSIZE = "SAGA_RESAMPLING_REGION_CELLSIZE"
SAGA_FOLDER = "SAGA_FOLDER"
SAGA_IMPORT_EXPORT_OPTIMIZATION = "SAGA_IMPORT_EXPORT_OPTIMIZATION"


@staticmethod
def sagaBatchJobFilename():

0 comments on commit 788407a

Please sign in to comment.