• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python SagaUtils.SagaUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sextante.saga.SagaUtils.SagaUtils的典型用法代码示例。如果您正苦于以下问题:Python SagaUtils类的具体用法?Python SagaUtils怎么用?Python SagaUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SagaUtils类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: processAlgorithm

    def processAlgorithm(self, progress):
        #TODO:check correct num of bands
        input = self.getParameterValue(SplitRGBBands.INPUT)
        temp = SextanteUtils.getTempFilename(None).replace('.','');
        basename = os.path.basename(temp)
        validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        safeBasename = ''.join(c for c in basename if c in validChars)
        temp = os.path.join(os.path.dirname(temp), safeBasename)

        r = self.getOutputValue(SplitRGBBands.R)
        g = self.getOutputValue(SplitRGBBands.G)
        b = self.getOutputValue(SplitRGBBands.B)
        commands = []
        if SextanteUtils.isWindows():
            commands.append("io_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input+"\"")
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");
        else:
            commands.append("libio_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input + "\"")
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");

        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
        SagaUtils.executeSaga(progress);
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:26,代码来源:SplitRGBBands.py


示例2: checkBeforeOpeningParametersDialog

 def checkBeforeOpeningParametersDialog(self):
     msg = SagaUtils.checkSagaIsInstalled()
     if msg is not None:
         html = ("<p>This algorithm requires SAGA to be run."
         "Unfortunately, it seems that SAGA is not installed in your system, or it is not correctly configured to be used from QGIS</p>")
         html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with SEXTANTE</p>'
         return html
开发者ID:drgalindog,项目名称:Quantum-GIS,代码行数:7,代码来源:SagaAlgorithm.py


示例3: initializeSettings

 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     if SextanteUtils.isWindows():
         SextanteConfig.addSetting(
             Setting(self.getDescription(), SagaUtils.SAGA_FOLDER, "SAGA folder", SagaUtils.sagaPath())
         )
     SextanteConfig.addSetting(
         Setting(
             self.getDescription(),
             SagaUtils.SAGA_AUTO_RESAMPLING,
             "Use min covering grid system for resampling",
             True,
         )
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_LOG_COMMANDS, "Log execution commands", False)
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_LOG_CONSOLE, "Log console output", False)
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMIN, "Resampling region min x", 0)
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_YMIN, "Resampling region min y", 0)
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMAX, "Resampling region max x", 1000)
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_YMAX, "Resampling region max y", 1000)
     )
     SextanteConfig.addSetting(
         Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_CELLSIZE, "Resampling region cellsize", 1)
     )
开发者ID:rudivs,项目名称:Quantum-GIS,代码行数:35,代码来源:SagaAlgorithmProvider.py


示例4: processAlgorithm

    def processAlgorithm(self, progress):
        #TODO:check correct num of bands
        input = self.getParameterValue(SplitRGBBands.INPUT)        
        temp = SextanteUtils.getTempFilename();        
        r = self.getOutputValue(SplitRGBBands.R)
        g = self.getOutputValue(SplitRGBBands.G)
        b = self.getOutputValue(SplitRGBBands.B)
        commands = []
        if SextanteUtils.isWindows():
            commands.append("io_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input+"\"")
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
            commands.append("io_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");            
        else:
            commands.append("libio_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input + "\"")
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
            commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");                        

        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)            
        SagaUtils.executeSaga(progress);
开发者ID:geolab,项目名称:Quantum-GIS,代码行数:21,代码来源:SplitRGBBands.py


示例5: getPostProcessingErrorMessage

 def getPostProcessingErrorMessage(self, wrongLayers):
     html = AlgorithmProvider.getPostProcessingErrorMessage(self, wrongLayers)        
     msg = SagaUtils.checkSagaIsInstalled(True)
     html += ("<p>This algorithm requires SAGA to be run. A test to check if SAGA is correctly installed " 
             "and configured in your system has been performed, with the following result:</p><ul><i>")
     if msg is None:
         html += "Saga seems to be correctly installed and configured</li></ul>"
     else:
         html += msg + "</i></li></ul>"
         html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with SEXTANTE</p>'
          
     return html
开发者ID:jesusjl,项目名称:Quantum-GIS,代码行数:12,代码来源:SagaAlgorithmProvider.py


示例6: createAlgsList

 def createAlgsList(self):
     self.preloadedAlgs = []
     folder = SagaUtils.sagaDescriptionPath()
     for descriptionFile in os.listdir(folder):
         if descriptionFile.endswith("txt"):
             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)
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:13,代码来源:SagaAlgorithmProvider.py


示例7: checkBeforeOpeningParametersDialog

 def checkBeforeOpeningParametersDialog(self):
     if SextanteUtils.isWindows():
         path = SagaUtils.sagaPath()
         if path == "":
             return "SAGA folder is not configured.\nPlease configure it before running SAGA algorithms."
     else:
         SAGA_INSTALLED = "SAGA_INSTALLED"
         settings = QSettings()
         if settings.contains(SAGA_INSTALLED):
             return
         command = ["saga_cmd"]
         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 "________" in line:
                 settings.setValue(SAGA_INSTALLED, True)
                 return
         return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:17,代码来源:SagaAlgorithm.py


示例8: createAlgsList

 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))
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:19,代码来源:SagaAlgorithmProvider.py


示例9: processAlgorithm

    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]));
#.........这里部分代码省略.........
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:101,代码来源:SagaAlgorithm.py



注:本文中的sextante.saga.SagaUtils.SagaUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rspec.RSpec类代码示例发布时间:2022-05-27
下一篇:
Python ParameterFactory.ParameterFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap