def getConsoleCommands(self, parameters, context, feedback, executing=True): 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 list_file = GdalUtils.writeLayerParameterToTextFile( filename='buildvrtInputFiles.txt', alg=self, parameters=parameters, parameter_name=self.INPUT, context=context, executing=executing, quote=False) arguments.append('-input_file_list') arguments.append(list_file) out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context) arguments.append(out) return ['gdalbuildvrt', GdalUtils.escapeAndJoin(arguments)]
def getConsoleCommands(self, parameters, context, feedback, executing=True): out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context) arguments = [] if self.parameterAsBool(parameters, self.PCT, context): arguments.append('-pct') if self.parameterAsBool(parameters, self.SEPARATE, context): arguments.append('-separate') if self.NODATA_INPUT in parameters and parameters[ self.NODATA_INPUT] is not None: nodata_input = self.parameterAsInt(parameters, self.NODATA_INPUT, context) arguments.append('-n') arguments.append(str(nodata_input)) if self.NODATA_OUTPUT in parameters and parameters[ self.NODATA_OUTPUT] is not None: nodata_output = self.parameterAsInt(parameters, self.NODATA_OUTPUT, context) arguments.append('-a_nodata') arguments.append(str(nodata_output)) arguments.append('-ot') arguments.append(self.TYPES[self.parameterAsEnum( parameters, self.DATA_TYPE, context)]) arguments.append('-of') arguments.append( QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1])) options = self.parameterAsString(parameters, self.OPTIONS, context) if options: arguments.extend(GdalUtils.parseCreationOptions(options)) arguments.append('-o') arguments.append(out) # 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 list_file = GdalUtils.writeLayerParameterToTextFile( filename='mergeInputFiles.txt', alg=self, parameters=parameters, parameter_name=self.INPUT, context=context, quote=True, executing=executing) arguments.append('--optfile') arguments.append(list_file) commands = [] if isWindows(): commands = [ 'cmd.exe', '/C ', 'gdal_merge.bat', GdalUtils.escapeAndJoin(arguments) ] else: commands = ['gdal_merge.py', GdalUtils.escapeAndJoin(arguments)] return commands