コード例 #1
0
 def unload(self):
     self.toolbox.setVisible(False)
     self.menu.deleteLater()
     #delete temporary output files
     folder = SextanteUtils.tempFolder()
     if QDir(folder).exists():
         shutil.rmtree(folder, True)
コード例 #2
0
ファイル: SextantePlugin.py プロジェクト: glien/Quantum-GIS
 def unload(self):
     self.toolbox.setVisible(False)
     self.menu.deleteLater()
     #delete temporary output files
     folder = SextanteUtils.tempFolder()
     if QDir(folder).exists():
         shutil.rmtree(folder, True)
コード例 #3
0
    def unload(self):
        self.toolbox.setVisible(False)
        self.menu.deleteLater()
        #delete temporary output files
        folder = SextanteUtils.tempFolder()
        if QDir(folder).exists():
            shutil.rmtree(folder, True)

        self.iface.unregisterMainWindowAction(self.commanderAction)
コード例 #4
0
    def unload(self):
        self.toolbox.setVisible(False)
        self.menu.deleteLater()
        #delete temporary output files
        folder = SextanteUtils.tempFolder()
        if QDir(folder).exists():
            shutil.rmtree(folder, True)

        self.iface.unregisterMainWindowAction(self.commanderAction)
コード例 #5
0
 def unload(self):
     self.toolbox.setVisible(False)
     self.menu.deleteLater()
     #delete temporary output files
     folder = SextanteUtils.tempFolder()
     for f in os.listdir(folder):
         path = os.path.join(folder,f)
         try:
             os.unlink(path)
         except:
             #leave files that could not be deleted
             pass
コード例 #6
0
 def unload(self):
     self.toolbox.setVisible(False)
     self.menu.deleteLater()
     #delete temporary output files
     folder = SextanteUtils.tempFolder()
     for f in os.listdir(folder):
         path = os.path.join(folder, f)
         try:
             os.unlink(path)
         except:
             #leave files that could not be deleted
             pass
コード例 #7
0
ファイル: SextanteConfig.py プロジェクト: sdikiy/Quantum-GIS
 def initialize():
     icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
     SextanteConfig.settingIcons["General"] = icon
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.USE_THREADS,
                 "Run algorithms in a new thread (still unstable)", False))
     SextanteConfig.addSetting(
         Setting(
             "General", SextanteConfig.SHOW_DEBUG_IN_DIALOG,
             "Show debug information and commands executed in the execution dialog's Log panel (threaded execution only)",
             True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.KEEP_DIALOG_OPEN,
                 "Keep dialog open after running an algorithm", False))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.USE_SELECTED,
                 "Use only selected features in external applications",
                 True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL,
                 "Show table-like parameter panels", False))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME,
                 "Use filename as layer name", True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS,
                 "Show recently executed algorithms", True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.OUTPUT_FOLDER, "Output folder",
                 SextanteUtils.tempFolder()))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.RASTER_STYLE,
                 "Style for raster layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_POINT_STYLE,
                 "Style for point layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_LINE_STYLE,
                 "Style for line layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,
                 "Style for polygon layers", ""))
     SextanteConfig.addSetting(
         Setting("General",
                 SextanteConfig.RECENT_ALGORITHMS,
                 "Recent algs",
                 "",
                 hidden=True))
コード例 #8
0
 def initialize():
     icon =  QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
     SextanteConfig.settingIcons["General"] = icon
     SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_THREADS, "Run algorithms in a new thread (still unstable)", False))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_DEBUG_IN_DIALOG, "Show debug information and commands executed in the execution dialog's Log panel (threaded execution only)", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.KEEP_DIALOG_OPEN, "Keep dialog open after running an algorithm", False))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_SELECTED, "Use only selected features in external applications", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.OUTPUT_FOLDER,
                                        "Output folder", SextanteUtils.tempFolder()))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.RASTER_STYLE,"Style for raster layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POINT_STYLE,"Style for point layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_LINE_STYLE,"Style for line layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,"Style for polygon layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.RECENT_ALGORITHMS,"Recent algs","", hidden=True))
コード例 #9
0
    def getHtmlFile(self, alg, helpFile):
        if not os.path.exists(helpFile):
            return None
        self.alg = alg
        f = open(helpFile, "rb")
        self.descriptions = pickle.load(f)
        s = "<h2>Algorithm description</h2>\n"
        s += "<p>" + self.getDescription(self.ALG_DESC) + "</p>\n"
        s += "<h2>Input parameters</h2>\n"
        for param in self.alg.parameters:
            s += "<h3>" + param.description + "</h3>\n"
            s += "<p>" + self.getDescription(param.name) + "</p>\n"
        s += "<h2>Outputs</h2>\n"
        for out in self.alg.outputs:
            s += "<h3>" + out.description + "</h3>\n"
            s += "<p>" + self.getDescription(out.name) + "</p>\n"
        filename = SextanteUtils.tempFolder() + os.sep + "temphelp.html"
        tempHtml = open(filename, "w")
        tempHtml.write(s)

        return filename
コード例 #10
0
ファイル: GrassUtils.py プロジェクト: Nald/Quantum-GIS
 def grassDataFolder():
     tempfolder = os.path.join(SextanteUtils.tempFolder(), "grassdata")
     mkdir(tempfolder)
     return tempfolder
コード例 #11
0
 def initialize():
     icon =  QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
     SextanteConfig.settingIcons["General"] = icon
     SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_THREADS, "Run algorithms in a new thread", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_DEBUG_IN_DIALOG, "Show extra info in Log panel (threaded execution only)", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.KEEP_DIALOG_OPEN, "Keep dialog open after running an algorithm", False))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_SELECTED, "Use only selected features", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.OUTPUT_FOLDER, "Output folder", SextanteUtils.tempFolder()))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_CRS_DEF, "Show layer CRS definition in selection boxes", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.WARN_UNMATCHING_CRS, "Warn before executing if layer CRS's do not match", True))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.RASTER_STYLE,"Style for raster layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POINT_STYLE,"Style for point layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_LINE_STYLE,"Style for line layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,"Style for polygon layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,"Style for polygon layers",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.PRE_EXECUTION_SCRIPT,"Pre-execution script",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.POST_EXECUTION_SCRIPT,"Post-execution script",""))
     SextanteConfig.addSetting(Setting("General", SextanteConfig.RECENT_ALGORITHMS,"Recent algs","", hidden=True))
コード例 #12
0
 def grassDataFolder():
     tempfolder = os.path.join(SextanteUtils.tempFolder(), "grassdata")
     mkdir(tempfolder)
     return tempfolder
コード例 #13
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():
            command = self.undecoratedGroup  + " \"" + self.cmdname + "\""
        else:
            command = "lib" + self.undecoratedGroup  + " \"" + self.cmdname + "\""

        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 = out.value
                #===============================================================
                # if not filename.endswith(".tif"):
                #    filename += ".tif"
                #    out.value = filename
                #===============================================================
                filename = SextanteUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
                command+=(" -" + out.name + " \"" + filename + "\"");
            if isinstance(out, OutputVector):
                filename = out.getCompatibleFileName(self)#out.value
                #===============================================================
                # if not filename.endswith(".shp"):
                #    filename += ".shp"
                #    out.value = filename
                #===============================================================
                command+=(" -" + out.name + " \"" + filename + "\"");
            if isinstance(out, OutputTable):
                filename = out.getCompatibleFileName(self)#out.value
                #===============================================================
                # if not filename.endswith(".dbf"):
                #    filename += ".dbf"
                #    out.value = filename
                #===============================================================
                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():
                    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);
コード例 #14
0
 def initialize():
     icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
     SextanteConfig.settingIcons["General"] = icon
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.USE_THREADS,
                 "Run algorithms in a new thread (still unstable)", True))
     SextanteConfig.addSetting(
         Setting(
             "General", SextanteConfig.SHOW_DEBUG_IN_DIALOG,
             "Show debug information and commands executed in the execution dialog's Log panel (threaded execution only)",
             True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.KEEP_DIALOG_OPEN,
                 "Keep dialog open after running an algorithm", False))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.USE_SELECTED,
                 "Use only selected features", True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL,
                 "Show table-like parameter panels", False))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME,
                 "Use filename as layer name", True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS,
                 "Show recently executed algorithms", True))
     SextanteConfig.addSetting(
         Setting(
             "General", SextanteConfig.USE_CATEGORIES,
             "Use categories to classify algorithms, instead of providers",
             True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.OUTPUT_FOLDER, "Output folder",
                 SextanteUtils.tempFolder()))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.SHOW_CRS_DEF,
                 "Show layer CRS definition in selection boxes", True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.WARN_UNMATCHING_CRS,
                 "Warn before executing if layer CRS's do not match", True))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.RASTER_STYLE,
                 "Style for raster layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_POINT_STYLE,
                 "Style for point layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_LINE_STYLE,
                 "Style for line layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,
                 "Style for polygon layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.VECTOR_POLYGON_STYLE,
                 "Style for polygon layers", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.PRE_EXECUTION_SCRIPT,
                 "Pre-execution script", ""))
     SextanteConfig.addSetting(
         Setting("General", SextanteConfig.POST_EXECUTION_SCRIPT,
                 "Post-execution script", ""))
     SextanteConfig.addSetting(
         Setting("General",
                 SextanteConfig.RECENT_ALGORITHMS,
                 "Recent algs",
                 "",
                 hidden=True))
コード例 #15
0
ファイル: GrassUtils.py プロジェクト: hCivil/Quantum-GIS
 def grassMapsetFolder():
     tempfolder = os.path.join(SextanteUtils.tempFolder(), "grassdata", "temp_location")
     mkdir(tempfolder)
     return tempfolder
コード例 #16
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)
コード例 #17
0
 def grassMapsetFolder():
     tempfolder = os.path.join(SextanteUtils.tempFolder(), "grassdata",
                               "temp_location")
     mkdir(tempfolder)
     return tempfolder