本文整理汇总了Python中qgis.core.QgsProcessingOutputLayerDefinition.sink方法的典型用法代码示例。如果您正苦于以下问题:Python QgsProcessingOutputLayerDefinition.sink方法的具体用法?Python QgsProcessingOutputLayerDefinition.sink怎么用?Python QgsProcessingOutputLayerDefinition.sink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsProcessingOutputLayerDefinition
的用法示例。
在下文中一共展示了QgsProcessingOutputLayerDefinition.sink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getParamValues
# 需要导入模块: from qgis.core import QgsProcessingOutputLayerDefinition [as 别名]
# 或者: from qgis.core.QgsProcessingOutputLayerDefinition import sink [as 别名]
def getParamValues(self):
if self.mUpdateExistingGroupBox.isChecked():
fieldName = self.mExistingFieldComboBox.currentText()
else:
fieldName = self.mOutputFieldNameLineEdit.text()
layer = self.cmbInputLayer.currentLayer()
context = dataobjects.createContext()
parameters = {}
parameters['INPUT'] = layer
parameters['FIELD_NAME'] = fieldName
parameters['FIELD_TYPE'] = self.mOutputFieldTypeComboBox.currentIndex()
parameters['FIELD_LENGTH'] = self.mOutputFieldWidthSpinBox.value()
parameters['FIELD_PRECISION'] = self.mOutputFieldPrecisionSpinBox.value()
parameters['NEW_FIELD'] = self.mNewFieldGroupBox.isChecked()
parameters['FORMULA'] = self.builder.expressionText()
output = QgsProcessingOutputLayerDefinition()
if self.leOutputFile.text().strip():
output.sink = QgsProperty.fromValue(self.leOutputFile.text().strip())
else:
output.sink = QgsProperty.fromValue('memory:')
output.destinationProject = context.project()
parameters['OUTPUT'] = output
ok, msg = self.alg.checkParameterValues(parameters, context)
if not ok:
QMessageBox.warning(
self, self.tr('Unable to execute algorithm'), msg)
return {}
return parameters
示例2: getConsoleCommands
# 需要导入模块: from qgis.core import QgsProcessingOutputLayerDefinition [as 别名]
# 或者: from qgis.core.QgsProcessingOutputLayerDefinition import sink [as 别名]
def getConsoleCommands(self, parameters, context, feedback):
arguments = []
arguments.append('-resolution')
arguments.append(self.RESOLUTION_OPTIONS[self.parameterAsEnum(parameters, self.RESOLUTION, context)])
if self.parameterAsBool(parameters, buildvrt.SEPARATE, context):
arguments.append('-separate')
if self.parameterAsBool(parameters, buildvrt.PROJ_DIFFERENCE, context):
arguments.append('-allow_projection_difference')
# Always write input files to a text file in case there are many of them and the
# length of the command will be longer then allowed in command prompt
listFile = os.path.join(QgsProcessingUtils.tempFolder(), 'buildvrtInputFiles.txt')
with open(listFile, 'w') as f:
layers = []
for l in self.parameterAsLayerList(parameters, self.INPUT, context):
layers.append(l.source())
f.write('\n'.join(layers))
arguments.append('-input_file_list')
arguments.append(listFile)
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
# Ideally the file extensions should be limited to just .vrt but I'm not sure how
# to do it simply so instead a check is performed.
_, ext = os.path.splitext(out)
if not ext.lower() == '.vrt':
out = out[:-len(ext)] + '.vrt'
if isinstance(parameters[self.OUTPUT], QgsProcessingOutputLayerDefinition):
output_def = QgsProcessingOutputLayerDefinition(parameters[self.OUTPUT])
output_def.sink = QgsProperty.fromValue(out)
self.setOutputValue(self.OUTPUT, output_def)
else:
self.setOutputValue(self.OUTPUT, out)
arguments.append(out)
return ['gdalbuildvrt', GdalUtils.escapeAndJoin(arguments)]