コード例 #1
0
 def otbPath():
     folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
     if folder == None:
         folder = ""
         #try to configure the path automatically
         if SextanteUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()),
                                       "bin")
             if os.path.exists(os.path.join(testfolder, "otbcli")):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/bin"
                 if os.path.exists(os.path.join(testfolder, "otbcli")):
                     folder = testfolder
         elif SextanteUtils.isWindows():
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
             testfolder = os.path.dirname(testfolder)
             testfolder = os.path.join(testfolder, "bin")
             path = os.path.join(testfolder, "otbcli.bat")
             if os.path.exists(path):
                 folder = testfolder
         else:
             testfolder = "/usr/bin"
             if os.path.exists(os.path.join(testfolder, "otbcli")):
                 folder = testfolder
     return folder
コード例 #2
0
 def exportRasterLayer(self, layer):
     destFilename = SextanteUtils.getTempFilenameInTempFolder(os.path.basename(layer)[0:5] + ".sgrd")
     self.exportedLayers[layer] = destFilename
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         return 'io_gdal 0 -GRIDS "' + destFilename + '" -FILES "' + layer + '"'
     else:
         return 'libio_gdal 0 -GRIDS "' + destFilename + '" -FILES "' + layer + '"'
コード例 #3
0
 def otbLibPath():
     folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
     if folder == None:
         folder = ""
         #try to configure the path automatically
         if SextanteUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()),
                                       "lib/otb/applications")
             if os.path.exists(testfolder):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/lib/otb/applications"
                 if os.path.exists(testfolder):
                     folder = testfolder
         elif SextanteUtils.isWindows():
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
             testfolder = os.path.join(testfolder, "orfeotoolbox")
             testfolder = os.path.join(testfolder, "applications")
             if os.path.exists(testfolder):
                 folder = testfolder
         else:
             testfolder = "/usr/lib/otb/applications"
             if os.path.exists(testfolder):
                 folder = testfolder
     return folder
コード例 #4
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
         SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
     SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
     SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
コード例 #5
0
ファイル: OTBUtils.py プロジェクト: geodenilson/Quantum-GIS
 def otbPath():
     folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
     if folder == None:
         folder = ""
         #try to configure the path automatically
         if SextanteUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
             if os.path.exists(os.path.join(testfolder, "otbcli")):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/bin"
                 if os.path.exists(os.path.join(testfolder, "otbcli")):
                     folder = testfolder
         elif SextanteUtils.isWindows():
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
             testfolder = os.path.dirname(testfolder)
             testfolder = os.path.join(testfolder,  "bin")
             path = os.path.join(testfolder, "otbcli.bat")
             if os.path.exists(path):
                 folder = testfolder
         else:
             testfolder = "/usr/bin"
             if os.path.exists(os.path.join(testfolder, "otbcli")):
                 folder = testfolder
     return folder
コード例 #6
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.addSetting(
             Setting(self.getDescription(), GrassUtils.GRASS_FOLDER,
                     "GRASS folder", GrassUtils.grassPath()))
         SextanteConfig.addSetting(
             Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL,
                     "Msys folder", GrassUtils.grassWinShell()))
     SextanteConfig.addSetting(
         Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS,
                 "Log execution commands", False))
     SextanteConfig.addSetting(
         Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE,
                 "Log console output", False))
     #SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_AUTO_REGION, "Use min covering region", True))
     SextanteConfig.addSetting(
         Setting(self.getDescription(), GrassUtils.GRASS_LATLON,
                 "Coordinates are lat/lon", False))
     #=======================================================================
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_XMIN, "GRASS Region min x", 0))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_YMIN, "GRASS Region min y", 0))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_XMAX, "GRASS Region max x", 1000))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_YMAX, "GRASS Region max y", 1000))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_CELLSIZE, "GRASS Region cellsize", 100))
     #=======================================================================
     SextanteConfig.addSetting(
         Setting(self.getDescription(), GrassUtils.GRASS_HELP_FOLDER,
                 "GRASS help folder", GrassUtils.grassHelpPath()))
コード例 #7
0
 def unload(self):
     AlgorithmProvider.unload(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
         SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
コード例 #8
0
 def unload(self):
     AlgorithmProvider.unload(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
         SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
コード例 #9
0
ファイル: GrassUtils.py プロジェクト: mokerjoke/Quantum-GIS
 def executeGrass(commands, progress):
     if SextanteUtils.isWindows():
         GrassUtils.createGrassScript(commands)
         command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
     else:
         gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
         os.putenv("GISRC", gisrc)
         os.putenv("GRASS_MESSAGE_FORMAT", "gui")
         os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
         GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
         os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
         if SextanteUtils.isMac():
             command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/user"
         else:
             command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"
     loglines = []
     loglines.append("GRASS execution console output")
     proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
     for line in iter(proc.readline, ""):
         if "GRASS_INFO_PERCENT" in line:
             try:
                 progress.setPercentage(int(line[len("GRASS_INFO_PERCENT")+ 2:]))
             except:
                 pass
         else:
             loglines.append(line)
             progress.setConsoleInfo(line)
     if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
         SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
     shutil.rmtree(GrassUtils.grassMapsetFolder(), True)
コード例 #10
0
 def executeGrass(commands, progress):
     if SextanteUtils.isWindows():
         GrassUtils.createGrassScript(commands)
         command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
     else:
         gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
         os.putenv("GISRC", gisrc)
         os.putenv("GRASS_MESSAGE_FORMAT", "gui")
         os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
         GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
         os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
         if SextanteUtils.isMac():
             command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/user"
         else:
             command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"
     loglines = []
     loglines.append("GRASS execution console output")
     proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
     for line in iter(proc.readline, ""):
         if "GRASS_INFO_PERCENT" in line:
             try:
                 progress.setPercentage(int(line[len("GRASS_INFO_PERCENT")+ 2:]))
             except:
                 pass
         else:
             loglines.append(line)
             progress.setConsoleInfo(line)
     if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
         SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
コード例 #11
0
 def exportRasterLayer(self, layer):
     destFilename = SextanteUtils.getTempFilenameInTempFolder(
         os.path.basename(layer)[0:5] + ".sgrd")
     self.exportedLayers[layer] = destFilename
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\""
     else:
         return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\""
コード例 #12
0
    def mpiexecPath():
        folder = SextanteConfig.getSetting(TauDEMUtils.MPIEXEC_FOLDER)
        if folder == None:
            folder = ""

        if SextanteUtils.isMac():
            testfolder = os.path.join(QgsApplication.prefixPath(), "bin")
            if os.path.exists(os.path.join(testfolder, "mpiexec")):
                folder = testfolder
            else:
                testfolder = "/usr/local/bin"
                if os.path.exists(os.path.join(testfolder, "mpiexec")):
                    folder = testfolder
        return folder
コード例 #13
0
    def sagaPath():
        folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
        if folder == None:
            folder = ""

        if SextanteUtils.isMac():
            testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
            if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                folder = testfolder
            else:
                testfolder = "/usr/local/bin"
                if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                    folder = testfolder
        return folder
コード例 #14
0
    def taudemPath():
        folder = SextanteConfig.getSetting(TauDEMUtils.TAUDEM_FOLDER)
        if folder == None:
            folder = ""

        if SextanteUtils.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
コード例 #15
0
    def sagaPath():
        folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
        if folder == None:
            folder =""

        if SextanteUtils.isMac():
            testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
            if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                folder = testfolder
            else:
                testfolder = "/usr/local/bin"
                if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                    folder = testfolder
        return folder
コード例 #16
0
ファイル: TauDEMUtils.py プロジェクト: Hardysong/Quantum-GIS
    def taudemPath():
        folder = SextanteConfig.getSetting(TauDEMUtils.TAUDEM_FOLDER)
        if folder == None:
            folder = ""

        if SextanteUtils.isMac():
            testfolder = os.path.join(str(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
コード例 #17
0
ファイル: TauDEMUtils.py プロジェクト: Hardysong/Quantum-GIS
    def mpiexecPath():
        folder = SextanteConfig.getSetting(TauDEMUtils.MPIEXEC_FOLDER)
        if folder == None:
            folder = ""

        if SextanteUtils.isMac():
            testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
            if os.path.exists(os.path.join(testfolder, "mpiexec")):
                folder = testfolder
            else:
                testfolder = "/usr/local/bin"
                if os.path.exists(os.path.join(testfolder, "mpiexec")):
                    folder = testfolder
        return folder
コード例 #18
0
 def resampleRasterLayer(self,layer):
     '''this is supposed to be run after having exported all raster layers'''
     if layer in self.exportedLayers.keys():
         inputFilename = self.exportedLayers[layer]
     else:
         inputFilename = layer
     destFilename = SextanteUtils.getTempFilename("sgrd")
     self.exportedLayers[layer]= destFilename
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         s = "grid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
             str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX "  + str(self.ymax) +\
             " -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
     else:
         s = "libgrid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
             str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX "  + str(self.ymax) +\
             " -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
     return s
コード例 #19
0
 def unload(self):
     AlgorithmProvider.unload(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
         SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
     #SextanteConfig.removeSetting(GrassUtils.GRASS_AUTO_REGION)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LATLON)
     #=======================================================================
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_XMIN)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_YMIN)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_XMAX)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_YMAX)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_CELLSIZE)
     #=======================================================================
     SextanteConfig.removeSetting(GrassUtils.GRASS_HELP_FOLDER)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
コード例 #20
0
 def unload(self):
     AlgorithmProvider.unload(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
         SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
     #SextanteConfig.removeSetting(GrassUtils.GRASS_AUTO_REGION)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LATLON)
     #=======================================================================
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_XMIN)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_YMIN)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_XMAX)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_YMAX)
     # SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_CELLSIZE)
     #=======================================================================
     SextanteConfig.removeSetting(GrassUtils.GRASS_HELP_FOLDER)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
     SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
コード例 #21
0
ファイル: GrassUtils.py プロジェクト: Nald/Quantum-GIS
    def prepareGrassExecution(commands):
        if SextanteUtils.isWindows():
            GrassUtils.createGrassScript(commands)
            command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
        else:
            gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
            os.putenv("GISRC", gisrc)
            os.putenv("GRASS_MESSAGE_FORMAT", "gui")
            os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
            GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
            os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
            if SextanteUtils.isMac():
                command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/PERMANENT"
            else:
                command = "grass64 " + GrassUtils.grassMapsetFolder() + "/PERMANENT"

        return command
コード例 #22
0
    def createSagaBatchJobFileFromSagaCommands(commands):

        fout = open(SagaUtils.sagaBatchJobFilename(), "w")
        if SextanteUtils.isWindows():
            fout.write("set SAGA=" + SagaUtils.sagaPath() + "\n");
            fout.write("set SAGA_MLB=" + SagaUtils.sagaPath() + os.sep + "modules" + "\n");
            fout.write("PATH=PATH;%SAGA%;%SAGA_MLB%\n");
        elif SextanteUtils.isMac():
            fout.write("export SAGA_MLB=" + SagaUtils.sagaPath() + "/../lib/saga\n");
            fout.write("export PATH=" + SagaUtils.sagaPath() + ":$PATH\n");
        else:
            pass
        for command in commands:
            fout.write("saga_cmd " + command.encode("utf8") + "\n")

        fout.write("exit")
        fout.close()
コード例 #23
0
    def prepareGrassExecution(commands):
        if SextanteUtils.isWindows():
            GrassUtils.createGrassScript(commands)
            command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
        else:
            gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
            os.putenv("GISRC", gisrc)
            os.putenv("GRASS_MESSAGE_FORMAT", "gui")
            os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
            GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
            os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
            if SextanteUtils.isMac():
                command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/PERMANENT"
            else:
                command = "grass64 " + GrassUtils.grassMapsetFolder() + "/PERMANENT"

        return command
コード例 #24
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
         SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
     SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
     SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
     #SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_AUTO_REGION, "Use min covering region", True))
     SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LATLON, "Coordinates are lat/lon", False))
     #=======================================================================
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_XMIN, "GRASS Region min x", 0))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_YMIN, "GRASS Region min y", 0))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_XMAX, "GRASS Region max x", 1000))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_YMAX, "GRASS Region max y", 1000))
     # SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_CELLSIZE, "GRASS Region cellsize", 100))
     #=======================================================================
     SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_HELP_FOLDER, "GRASS help folder", GrassUtils.grassHelpPath()))
コード例 #25
0
 def resampleRasterLayer(self, layer):
     '''this is supposed to be run after having exported all raster layers'''
     if layer in self.exportedLayers.keys():
         inputFilename = self.exportedLayers[layer]
     else:
         inputFilename = layer
     destFilename = SextanteUtils.getTempFilename("sgrd")
     self.exportedLayers[layer] = destFilename
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         s = "grid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
             str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX "  + str(self.ymax) +\
             " -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
     else:
         s = "libgrid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
             str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX "  + str(self.ymax) +\
             " -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
     return s
コード例 #26
0
 def resampleRasterLayer(self, layer):
     """this is supposed to be run after having exported all raster layers"""
     if layer in self.exportedLayers.keys():
         inputFilename = self.exportedLayers[layer]
     else:
         inputFilename = layer
     destFilename = SextanteUtils.getTempFilename("sgrd")
     self.exportedLayers[layer] = destFilename
     if SextanteUtils.isWindows() or SextanteUtils.isMac():
         s = (
             'grid_tools "Resampling" -INPUT "'
             + inputFilename
             + '" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN '
             + str(self.xmin)
             + " -USER_XMAX "
             + str(self.xmax)
             + " -USER_YMIN "
             + str(self.ymin)
             + " -USER_YMAX "
             + str(self.ymax)
             + " -USER_SIZE "
             + str(self.cellsize)
             + ' -USER_GRID "'
             + destFilename
             + '"'
         )
     else:
         s = (
             'libgrid_tools "Resampling" -INPUT "'
             + inputFilename
             + '" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN '
             + str(self.xmin)
             + " -USER_XMAX "
             + str(self.xmax)
             + " -USER_YMIN "
             + str(self.ymin)
             + " -USER_YMAX "
             + str(self.ymax)
             + " -USER_SIZE "
             + str(self.cellsize)
             + ' -USER_GRID "'
             + destFilename
             + '"'
         )
     return s
コード例 #27
0
ファイル: OTBUtils.py プロジェクト: PepSalehi/Quantum-GIS
    def otbLibPath():
        folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
        if folder == None:
            folder =""

            if SextanteUtils.isMac():
                testfolder = os.path.join(str(QgsApplication.prefixPath()), "lib/otb/applications")
                if os.path.exists(testfolder):
                    folder = testfolder
                else:
                    testfolder = "/usr/local/lib/otb/applications"
                    if os.path.exists(testfolder):
                        folder = testfolder
            else:
                testfolder = "/usr/lib/otb/applications"
                if os.path.exists(testfolder):
                    folder = testfolder
        return folder
コード例 #28
0
ファイル: OTBUtils.py プロジェクト: PepSalehi/Quantum-GIS
    def otbPath():
        folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
        if folder == None:
            folder = ""

            if SextanteUtils.isMac():
                testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
                if os.path.exists(os.path.join(testfolder, "otbcli")):
                    folder = testfolder
                else:
                    testfolder = "/usr/local/bin"
                    if os.path.exists(os.path.join(testfolder, "otbcli")):
                        folder = testfolder
            else:
                testfolder = "/usr/bin"
                if os.path.exists(os.path.join(testfolder, "otbcli")):
                    folder = testfolder
        return folder
コード例 #29
0
    def createSagaBatchJobFileFromSagaCommands(commands):

        fout = open(SagaUtils.sagaBatchJobFilename(), "w")
        if SextanteUtils.isWindows():
            fout.write("set SAGA=" + SagaUtils.sagaPath() + "\n")
            fout.write("set SAGA_MLB=" + SagaUtils.sagaPath() + os.sep +
                       "modules" + "\n")
            fout.write("PATH=PATH;%SAGA%;%SAGA_MLB%\n")
        elif SextanteUtils.isMac():
            fout.write("export SAGA_MLB=" + SagaUtils.sagaPath() +
                       "/../lib/saga\n")
            fout.write("export PATH=" + SagaUtils.sagaPath() + ":$PATH\n")
        else:
            pass
        for command in commands:
            fout.write("saga_cmd " + command.encode("utf8") + "\n")

        fout.write("exit")
        fout.close()
コード例 #30
0
ファイル: SagaUtils.py プロジェクト: geodenilson/Quantum-GIS
 def sagaPath():
     folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
     if folder == None:
         folder =""
         #try to auto-configure the folder
         if SextanteUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
             if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/bin"
                 if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                     folder = testfolder
         elif SextanteUtils.isWindows():                
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))                
             testfolder = os.path.join(testfolder,  "saga")                
             if os.path.exists(os.path.join(testfolder, "saga_cmd.exe")):
                 folder = testfolder
     return folder
コード例 #31
0
ファイル: OTBUtils.py プロジェクト: flight1973/Quantum-GIS
    def otbLibPath():
        folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
        if folder == None:
            folder = ""

            if SextanteUtils.isMac():
                testfolder = os.path.join(str(QgsApplication.prefixPath()),
                                          "lib/otb/applications")
                if os.path.exists(testfolder):
                    folder = testfolder
                else:
                    testfolder = "/usr/local/lib/otb/applications"
                    if os.path.exists(testfolder):
                        folder = testfolder
            else:
                testfolder = "/usr/lib/otb/applications"
                if os.path.exists(testfolder):
                    folder = testfolder
        return folder
コード例 #32
0
 def createAlgsList(self):
     self.preloadedAlgs = []
     folder = SagaUtils.sagaDescriptionPath()
     for descriptionFile in os.listdir(folder):
         if descriptionFile.endswith("txt"):
             if SextanteUtils.isWindows() or SextanteUtils.isMac():
                 if descriptionFile.startswith("2.0.8"):
                     continue
             else:
                 if descriptionFile.startswith("2.1"):
                     continue
             try:
                 alg = SagaAlgorithm(os.path.join(folder, descriptionFile))
                 if alg.name.strip() != "":
                     self.preloadedAlgs.append(alg)
                 else:
                     SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
             except Exception,e:
                 SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile +"\n" + str(e))
コード例 #33
0
ファイル: OTBUtils.py プロジェクト: flight1973/Quantum-GIS
    def otbPath():
        folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
        if folder == None:
            folder = ""

            if SextanteUtils.isMac():
                testfolder = os.path.join(str(QgsApplication.prefixPath()),
                                          "bin")
                if os.path.exists(os.path.join(testfolder, "otbcli")):
                    folder = testfolder
                else:
                    testfolder = "/usr/local/bin"
                    if os.path.exists(os.path.join(testfolder, "otbcli")):
                        folder = testfolder
            else:
                testfolder = "/usr/bin"
                if os.path.exists(os.path.join(testfolder, "otbcli")):
                    folder = testfolder
        return folder
コード例 #34
0
ファイル: GrassUtils.py プロジェクト: Nald/Quantum-GIS
    def grassPath():
        if not SextanteUtils.isWindows() and not SextanteUtils.isMac():
            return ""

        folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
        if folder == None:
            if SextanteUtils.isWindows():
                folder = plugin_installer.__file__
                idx = folder.find('qgis')
                folder = folder[:idx] + "grass"
                if not os.path.isdir(folder):
                    return ""
                for subfolder in os.listdir(folder):
                    if subfolder.startswith("grass"):
                        folder = folder + os.sep + subfolder
                        break
            else:
                return "/Applications/GRASS-6.4.app/Contents/MacOS"

        return folder
コード例 #35
0
ファイル: GrassUtils.py プロジェクト: geodenilson/Quantum-GIS
    def grassPath():
        if not SextanteUtils.isWindows() and not SextanteUtils.isMac():
            return ""

        folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
        if folder == None:
            if SextanteUtils.isWindows():                    
                testfolder = os.path.dirname(str(QgsApplication.prefixPath()))                                
                testfolder = os.path.join(testfolder,  "grass")
                if os.path.isdir(testfolder):                                                                
                    for subfolder in os.listdir(testfolder):
                        if subfolder.startswith("grass"):
                            folder = os.path.join(testfolder, subfolder)
                            break
            else:
                folder = os.path.join(str(QgsApplication.prefixPath()), "grass")
                if not os.path.isdir(folder):
                    folder = "/Applications/GRASS-6.4.app/Contents/MacOS"

        return folder
コード例 #36
0
    def grassPath():
        if not SextanteUtils.isWindows() and not SextanteUtils.isMac():
            return ""

        folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
        if folder == None:
            if SextanteUtils.isWindows():
                folder = plugin_installer.__file__
                idx = folder.find('qgis')
                folder = folder[:idx] + "grass"
                if not os.path.isdir(folder):
                    return ""
                for subfolder in os.listdir(folder):
                    if subfolder.startswith("grass"):
                        folder = folder + os.sep + subfolder
                        break
            else:
                return "/Applications/GRASS-6.4.app/Contents/MacOS"

        return folder
コード例 #37
0
    def grassPath():
        if not SextanteUtils.isWindows() and not SextanteUtils.isMac():
            return ""

        folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
        if folder == None:
            if SextanteUtils.isWindows():
                testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
                testfolder = os.path.join(testfolder,  "grass")
                if os.path.isdir(testfolder):
                    for subfolder in os.listdir(testfolder):
                        if subfolder.startswith("grass"):
                            folder = os.path.join(testfolder, subfolder)
                            break
            else:
                folder = os.path.join(str(QgsApplication.prefixPath()), "grass")
                if not os.path.isdir(folder):
                    folder = "/Applications/GRASS-6.4.app/Contents/MacOS"

        return folder
コード例 #38
0
 def sagaPath():
     folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
     if folder == None:
         folder = ""
         #try to auto-configure the folder
         if SextanteUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()),
                                       "bin")
             if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/bin"
                 if os.path.exists(os.path.join(testfolder, "saga_cmd")):
                     folder = testfolder
         elif SextanteUtils.isWindows():
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
             testfolder = os.path.join(testfolder, "saga")
             if os.path.exists(os.path.join(testfolder, "saga_cmd.exe")):
                 folder = testfolder
     return folder
コード例 #39
0
ファイル: OTBUtils.py プロジェクト: geodenilson/Quantum-GIS
 def otbLibPath():
     folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
     if folder == None:
         folder =""
         #try to configure the path automatically
         if SextanteUtils.isMac():
             testfolder = os.path.join(str(QgsApplication.prefixPath()), "lib/otb/applications")
             if os.path.exists(testfolder):
                 folder = testfolder
             else:
                 testfolder = "/usr/local/lib/otb/applications"
                 if os.path.exists(testfolder):
                     folder = testfolder                    
         elif SextanteUtils.isWindows():
             testfolder = os.path.dirname(str(QgsApplication.prefixPath()))                
             testfolder = os.path.join(testfolder,  "orfeotoolbox")
             testfolder = os.path.join(testfolder,  "applications")                
             if os.path.exists(testfolder):
                 folder = testfolder
         else:
             testfolder = "/usr/lib/otb/applications"
             if os.path.exists(testfolder):
                 folder = testfolder                                                        
     return folder
コード例 #40
0
    def processAlgorithm(self, progress):
        if SextanteUtils.isWindows():
            path = SagaUtils.sagaPath()
            if path == "":
                raise GeoAlgorithmExecutionException(
                    "SAGA folder is not configured.\nPlease configure it before running SAGA algorithms."
                )
        commands = list()
        self.exportedLayers = {}

        # 1: Export rasters to sgrd and vectors to shp
        #   Tables must be in dbf format. We check that.
        if self.resample:
            self.calculateResamplingExtent()
        for param in self.parameters:
            if isinstance(param, ParameterRaster):
                if param.value == None:
                    continue
                value = param.value
                if not value.endswith("sgrd"):
                    commands.append(self.exportRasterLayer(value))
                if self.resample:
                    commands.append(self.resampleRasterLayer(value))
            if isinstance(param, ParameterVector):
                if param.value == None:
                    continue
                layer = QGisLayers.getObjectFromUri(param.value, False)
                if layer:
                    filename = LayerExporter.exportVectorLayer(layer)
                    self.exportedLayers[param.value] = filename
                elif not param.value.endswith("shp"):
                    raise GeoAlgorithmExecutionException("Unsupported file format")
            if isinstance(param, ParameterTable):
                if param.value == None:
                    continue
                table = QGisLayers.getObjectFromUri(param.value, False)
                if table:
                    filename = LayerExporter.exportTable(table)
                    self.exportedLayers[param.value] = filename
                elif not param.value.endswith("shp"):
                    raise GeoAlgorithmExecutionException("Unsupported file format")
            if isinstance(param, ParameterMultipleInput):
                if param.value == None:
                    continue
                layers = param.value.split(";")
                if layers == None or len(layers) == 0:
                    continue
                if param.datatype == ParameterMultipleInput.TYPE_RASTER:
                    for layerfile in layers:
                        if not layerfile.endswith("sgrd"):
                            commands.append(self.exportRasterLayer(layerfile))
                        if self.resample:
                            commands.append(self.resampleRasterLayer(layerfile))
                elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
                    for layerfile in layers:
                        layer = QGisLayers.getObjectFromUri(layerfile, False)
                        if layer:
                            filename = LayerExporter.exportVectorLayer(layer)
                            self.exportedLayers[layerfile] = filename
                        elif not layerfile.endswith("shp"):
                            raise GeoAlgorithmExecutionException("Unsupported file format")

        # 2: set parameters and outputs
        if SextanteUtils.isWindows() or SextanteUtils.isMac():
            command = self.undecoratedGroup + ' "' + self.cmdname + '"'
        else:
            command = "lib" + self.undecoratedGroup + ' "' + self.cmdname + '"'

        if self.hardcodedStrings:
            for s in self.hardcodedStrings:
                command += " " + s

        for param in self.parameters:
            if param.value is None:
                continue
            if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable)):
                value = param.value
                if value in self.exportedLayers.keys():
                    command += " -" + param.name + ' "' + self.exportedLayers[value] + '"'
                else:
                    command += " -" + param.name + ' "' + value + '"'
            elif isinstance(param, ParameterMultipleInput):
                s = param.value
                for layer in self.exportedLayers.keys():
                    s = s.replace(layer, self.exportedLayers[layer])
                command += " -" + param.name + ' "' + s + '"'
            elif isinstance(param, ParameterBoolean):
                if param.value:
                    command += " -" + param.name
            elif isinstance(param, ParameterFixedTable):
                tempTableFile = SextanteUtils.getTempFilename("txt")
                f = open(tempTableFile, "w")
                f.write("\t".join([col for col in param.cols]) + "\n")
                values = param.value.split(",")
                for i in range(0, len(values), 3):
                    s = values[i] + "\t" + values[i + 1] + "\t" + values[i + 2] + "\n"
                    f.write(s)
                f.close()
                command += " -" + param.name + ' "' + tempTableFile + '"'
            elif isinstance(param, ParameterExtent):
                #'we have to substract/add half cell size, since saga is center based, not corner based
                halfcell = self.getOutputCellsize() / 2
                offset = [halfcell, -halfcell, halfcell, -halfcell]
                values = param.value.split(",")
                for i in range(4):
                    command += " -" + self.extentParamNames[i] + " " + str(float(values[i]) + offset[i])
            elif isinstance(param, (ParameterNumber, ParameterSelection)):
                command += " -" + param.name + " " + str(param.value)
            else:
                command += " -" + param.name + ' "' + str(param.value) + '"'

        for out in self.outputs:
            if isinstance(out, OutputRaster):
                filename = out.getCompatibleFileName(self)
                filename = SextanteUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
                command += " -" + out.name + ' "' + filename + '"'
            if isinstance(out, OutputVector):
                filename = out.getCompatibleFileName(self)
                command += " -" + out.name + ' "' + filename + '"'
            if isinstance(out, OutputTable):
                filename = out.getCompatibleFileName(self)
                command += " -" + out.name + ' "' + filename + '"'

        commands.append(command)

        # 3:Export resulting raster layers
        for out in self.outputs:
            if isinstance(out, OutputRaster):
                filename = out.getCompatibleFileName(self)
                filename2 = SextanteUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
                if SextanteUtils.isWindows() or SextanteUtils.isMac():
                    commands.append('io_gdal 1 -GRIDS "' + filename2 + '" -FORMAT 1 -TYPE 0 -FILE "' + filename + '"')
                else:
                    commands.append(
                        'libio_gdal 1 -GRIDS "' + filename2 + '" -FORMAT 1 -TYPE 0 -FILE "' + filename + '"'
                    )

        # 4 Run SAGA
        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
        loglines = []
        loglines.append("SAGA execution commands")
        for line in commands:
            progress.setCommand(line)
            loglines.append(line)
        if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
            SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
        SagaUtils.executeSaga(progress)
コード例 #41
0
    def processAlgorithm(self, progress):
        if SextanteUtils.isWindows():
            path = SagaUtils.sagaPath()
            if path == "":
                raise GeoAlgorithmExecutionException(
                    "SAGA folder is not configured.\nPlease configure it before running SAGA algorithms."
                )
        commands = list()
        self.exportedLayers = {}

        #1: Export rasters to sgrd and vectors to shp
        #   Tables must be in dbf format. We check that.
        if self.resample:
            self.calculateResamplingExtent()
        for param in self.parameters:
            if isinstance(param, ParameterRaster):
                if param.value == None:
                    continue
                value = param.value
                if not value.endswith("sgrd"):
                    commands.append(self.exportRasterLayer(value))
                if self.resample:
                    commands.append(self.resampleRasterLayer(value))
            if isinstance(param, ParameterVector):
                if param.value == None:
                    continue
                layer = QGisLayers.getObjectFromUri(param.value, False)
                if layer:
                    filename = LayerExporter.exportVectorLayer(layer)
                    self.exportedLayers[param.value] = filename
                elif not param.value.endswith("shp"):
                    raise GeoAlgorithmExecutionException(
                        "Unsupported file format")
            if isinstance(param, ParameterTable):
                if param.value == None:
                    continue
                table = QGisLayers.getObjectFromUri(param.value, False)
                if table:
                    filename = LayerExporter.exportTable(table)
                    self.exportedLayers[param.value] = filename
                elif not param.value.endswith("shp"):
                    raise GeoAlgorithmExecutionException(
                        "Unsupported file format")
            if isinstance(param, ParameterMultipleInput):
                if param.value == None:
                    continue
                layers = param.value.split(";")
                if layers == None or len(layers) == 0:
                    continue
                if param.datatype == ParameterMultipleInput.TYPE_RASTER:
                    for layerfile in layers:
                        if not layerfile.endswith("sgrd"):
                            commands.append(self.exportRasterLayer(layerfile))
                        if self.resample:
                            commands.append(
                                self.resampleRasterLayer(layerfile))
                elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
                    for layerfile in layers:
                        layer = QGisLayers.getObjectFromUri(layerfile, False)
                        if layer:
                            filename = LayerExporter.exportVectorLayer(layer)
                            self.exportedLayers[layerfile] = filename
                        elif (not layerfile.endswith("shp")):
                            raise GeoAlgorithmExecutionException(
                                "Unsupported file format")

        #2: set parameters and outputs
        if SextanteUtils.isWindows() or SextanteUtils.isMac():
            command = self.undecoratedGroup + " \"" + self.cmdname + "\""
        else:
            command = "lib" + self.undecoratedGroup + " \"" + self.cmdname + "\""

        if self.hardcodedStrings:
            for s in self.hardcodedStrings:
                command += " " + s

        for param in self.parameters:
            if param.value is None:
                continue
            if isinstance(param,
                          (ParameterRaster, ParameterVector, ParameterTable)):
                value = param.value
                if value in self.exportedLayers.keys():
                    command += (" -" + param.name + " \"" +
                                self.exportedLayers[value] + "\"")
                else:
                    command += (" -" + param.name + " \"" + value + "\"")
            elif isinstance(param, ParameterMultipleInput):
                s = param.value
                for layer in self.exportedLayers.keys():
                    s = s.replace(layer, self.exportedLayers[layer])
                command += (" -" + param.name + " \"" + s + "\"")
            elif isinstance(param, ParameterBoolean):
                if param.value:
                    command += (" -" + param.name)
            elif isinstance(param, ParameterFixedTable):
                tempTableFile = SextanteUtils.getTempFilename("txt")
                f = open(tempTableFile, "w")
                f.write('\t'.join([col for col in param.cols]) + "\n")
                values = param.value.split(",")
                for i in range(0, len(values), 3):
                    s = values[i] + "\t" + values[i +
                                                  1] + "\t" + values[i +
                                                                     2] + "\n"
                    f.write(s)
                f.close()
                command += (" -" + param.name + " \"" + tempTableFile + "\"")
            elif isinstance(param, ParameterExtent):
                #'we have to substract/add half cell size, since saga is center based, not corner based
                halfcell = self.getOutputCellsize() / 2
                offset = [halfcell, -halfcell, halfcell, -halfcell]
                values = param.value.split(",")
                for i in range(4):
                    command += (" -" + self.extentParamNames[i] + " " +
                                str(float(values[i]) + offset[i]))
            elif isinstance(param, (ParameterNumber, ParameterSelection)):
                command += (" -" + param.name + " " + str(param.value))
            else:
                command += (" -" + param.name + " \"" + str(param.value) +
                            "\"")

        for out in self.outputs:
            if isinstance(out, OutputRaster):
                filename = out.getCompatibleFileName(self)
                filename = SextanteUtils.tempFolder(
                ) + os.sep + os.path.basename(filename) + ".sgrd"
                command += (" -" + out.name + " \"" + filename + "\"")
            if isinstance(out, OutputVector):
                filename = out.getCompatibleFileName(self)
                command += (" -" + out.name + " \"" + filename + "\"")
            if isinstance(out, OutputTable):
                filename = out.getCompatibleFileName(self)
                command += (" -" + out.name + " \"" + filename + "\"")

        commands.append(command)

        #3:Export resulting raster layers
        for out in self.outputs:
            if isinstance(out, OutputRaster):
                filename = out.getCompatibleFileName(self)
                filename2 = SextanteUtils.tempFolder(
                ) + os.sep + os.path.basename(filename) + ".sgrd"
                if SextanteUtils.isWindows() or SextanteUtils.isMac():
                    commands.append("io_gdal 1 -GRIDS \"" + filename2 +
                                    "\" -FORMAT 1 -TYPE 0 -FILE \"" +
                                    filename + "\"")
                else:
                    commands.append("libio_gdal 1 -GRIDS \"" + filename2 +
                                    "\" -FORMAT 1 -TYPE 0 -FILE \"" +
                                    filename + "\"")

        #4 Run SAGA
        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
        loglines = []
        loglines.append("SAGA execution commands")
        for line in commands:
            progress.setCommand(line)
            loglines.append(line)
        if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
            SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
        SagaUtils.executeSaga(progress)