当前位置: 首页>>代码示例>>Python>>正文


Python OtbUtils.appFolder方法代码示例

本文整理汇总了Python中processing.algs.otb.OtbUtils.OtbUtils.appFolder方法的典型用法代码示例。如果您正苦于以下问题:Python OtbUtils.appFolder方法的具体用法?Python OtbUtils.appFolder怎么用?Python OtbUtils.appFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.algs.otb.OtbUtils.OtbUtils的用法示例。


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

示例1: load

# 需要导入模块: from processing.algs.otb.OtbUtils import OtbUtils [as 别名]
# 或者: from processing.algs.otb.OtbUtils.OtbUtils import appFolder [as 别名]
 def load(self):
     group = self.name()
     ProcessingConfig.settingIcons[group] = self.icon()
     ProcessingConfig.addSetting(Setting(group, OtbUtils.ACTIVATE, self.tr('Activate'), True))
     ProcessingConfig.addSetting(Setting(group, OtbUtils.FOLDER,
                                         self.tr("OTB folder"),
                                         OtbUtils.otbFolder(),
                                         valuetype=Setting.FOLDER,
                                         validator=self.validateOtbFolder
                                         ))
     ProcessingConfig.addSetting(Setting(group, OtbUtils.APP_FOLDER,
                                         self.tr("OTB application folder"),
                                         OtbUtils.appFolder(),
                                         valuetype=Setting.MULTIPLE_FOLDERS,
                                         validator=self.validateAppFolders
                                         ))
     ProcessingConfig.addSetting(Setting(group, OtbUtils.SRTM_FOLDER,
                                         self.tr("SRTM tiles folder"),
                                         OtbUtils.srtmFolder(),
                                         valuetype=Setting.FOLDER
                                         ))
     ProcessingConfig.addSetting(Setting(group, OtbUtils.GEOID_FILE,
                                         self.tr("Geoid file"),
                                         OtbUtils.geoidFile(),
                                         valuetype=Setting.FOLDER
                                         ))
     ProcessingConfig.addSetting(Setting(group, OtbUtils.MAX_RAM_HINT,
                                         self.tr("Maximum RAM to use"),
                                         OtbUtils.maxRAMHint(),
                                         valuetype=Setting.STRING
                                         ))
     ProcessingConfig.addSetting(Setting(group, OtbUtils.LOGGER_LEVEL,
                                         self.tr("Logger level"),
                                         OtbUtils.loggerLevel(),
                                         valuetype=Setting.STRING,
                                         validator=self.validateLoggerLevel
                                         ))
     ProcessingConfig.readSettings()
     self.refreshAlgorithms()
     return True
开发者ID:boundlessgeo,项目名称:QGIS,代码行数:42,代码来源:OtbAlgorithmProvider.py

示例2: processAlgorithm

# 需要导入模块: from processing.algs.otb.OtbUtils import OtbUtils [as 别名]
# 或者: from processing.algs.otb.OtbUtils.OtbUtils import appFolder [as 别名]
    def processAlgorithm(self, parameters, context, feedback):
        app_launcher_path = OtbUtils.getExecutableInPath(OtbUtils.otbFolder(), 'otbApplicationLauncherCommandLine')
        command = '"{}" {} {}'.format(app_launcher_path, self.name(), OtbUtils.appFolder())
        outputPixelType = None
        for k, v in parameters.items():
            # if value is None for a parameter we don't have any businees with this key
            if not v or v is None:
                continue
            # for 'outputpixeltype' parameter we find the pixeltype string from self.pixelTypes
            if k == 'outputpixeltype':
                pixel_type = self.pixelTypes[int(parameters['outputpixeltype'])]
                outputPixelType = None if pixel_type == 'float' else pixel_type
                continue

            param = self.parameterDefinition(k)
            if param.isDestination():
                continue
            if isinstance(param, QgsProcessingParameterEnum):
                value = self.parameterAsEnum(parameters, param.name(), context)
            elif isinstance(param, QgsProcessingParameterBoolean):
                value = self.parameterAsBoolean(parameters, param.name(), context)
            elif isinstance(param, QgsProcessingParameterCrs):
                crsValue = self.parameterAsCrs(parameters, param.name(), context)
                authid = crsValue.authid()
                if authid.startswith('EPSG:'):
                    value = authid.split('EPSG:')[1]
                else:
                    raise QgsProcessingException(
                        self.tr("Incorrect value for parameter '{}'. No EPSG code found in '{}'".format(
                            param.name(),
                            authid)))
            elif isinstance(param, QgsProcessingParameterFile):
                value = self.parameterAsFile(parameters, param.name(), context)
            elif isinstance(param, QgsProcessingParameterMultipleLayers):
                layers = self.parameterAsLayerList(parameters, param.name(), context)
                if layers is None or len(layers) == 0:
                    continue
                value = ' '.join(['"{}"'.format(self.getLayerSource(param.name(), layer)) for layer in layers])
            elif isinstance(param, QgsProcessingParameterNumber):
                if param.dataType() == QgsProcessingParameterNumber.Integer:
                    value = self.parameterAsInt(parameters, param.name(), context)
                else:
                    value = self.parameterAsDouble(parameters, param.name(), context)
            elif isinstance(param, (QgsProcessingParameterRasterLayer, QgsProcessingParameterVectorLayer)):
                value = '"{}"'.format(self.getLayerSource(param.name(), self.parameterAsLayer(parameters, param.name(), context)))
            elif isinstance(param, QgsProcessingParameterString):
                value = '"{}"'.format(self.parameterAsString(parameters, param.name(), context))
            else:
                # Use whatever is given
                value = '"{}"'.format(parameters[param.name()])

            # Check if value is set in above if elif ladder and update command string
            if value and value is not None:
                command += ' -{} {}'.format(k, value)

        output_files = {}

        for out in self.destinationParameterDefinitions():
            filePath = self.parameterAsOutputLayer(parameters, out.name(), context)
            if filePath:
                output_files[out.name()] = filePath
                if outputPixelType is not None:
                    command += ' -{} "{}" "{}"'.format(out.name(), filePath, outputPixelType)
                else:
                    command += ' -{} "{}"'.format(out.name(), filePath)

        OtbUtils.executeOtb(command, feedback)

        result = {}
        for o in self.outputDefinitions():
            if o.name() in output_files:
                result[o.name()] = output_files[o.name()]
        return result
开发者ID:m-kuhn,项目名称:QGIS,代码行数:75,代码来源:OtbAlgorithm.py


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