Exemplo n.º 1
0
 def defineCharacteristics(self):
     self.name = 'Grid Surface Create'
     self.group = 'Surface'
     self.addParameter(ParameterFile(self.INPUT, 'Input las layer'))
     self.addParameter(ParameterNumber(self.CELLSIZE, 'Cellsize', 0, None, 10.0))
     self.addParameter(ParameterSelection(self.XYUNITS, 'XY Units', self.UNITS))
     self.addParameter(ParameterSelection(self.ZUNITS, 'Z Units', self.UNITS))
     self.addOutput(OutputFile(self.OUTPUT_DTM, 'DTM Output Surface', 'dtm'))
     spike = ParameterString(self.SPIKE, 'Spike (set blank if not used)', '', False, True)
     spike.isAdvanced = True
     self.addParameter(spike)
     median = ParameterString(self.MEDIAN, 'Median', '', False, True)
     median.isAdvanced = True
     self.addParameter(median)
     smooth = ParameterString(self.SMOOTH, 'Smooth', '', False, True)
     smooth.isAdvanced = True
     self.addParameter(smooth)
     slope = ParameterString(self.SLOPE, 'Slope', '', False, True)
     slope.isAdvanced = True
     self.addParameter(slope)
     minimum = ParameterBoolean(self.MINIMUM, 'Minimum (set blank if not used)', False)
     minimum.isAdvanced = True
     self.addParameter(minimum)
     class_var = ParameterString(self.CLASS, 'Class(es)', 2, False, True)
     class_var.isAdvanced = True
     self.addParameter(class_var)
     advance_modifiers = ParameterString(self.ADVANCED_MODIFIERS, 'Additional modifiers', '', False, True)
     advance_modifiers.isAdvanced = True
     self.addParameter(advance_modifiers)
Exemplo n.º 2
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm("Grid Surface Create")
     self.group, self.i18n_group = self.trAlgorithm("Surface")
     self.addParameter(ParameterFile(self.INPUT, self.tr("Input LAS layer")))
     self.addParameter(ParameterNumber(self.CELLSIZE, self.tr("Cellsize"), 0, None, 10.0))
     self.addParameter(ParameterSelection(self.XYUNITS, self.tr("XY Units"), self.UNITS))
     self.addParameter(ParameterSelection(self.ZUNITS, self.tr("Z Units"), self.UNITS))
     self.addOutput(OutputFile(self.OUTPUT_DTM, self.tr("DTM Output Surface"), "dtm"))
     spike = ParameterString(self.SPIKE, self.tr("Spike (set blank if not used)"), "", False, True)
     spike.isAdvanced = True
     self.addParameter(spike)
     median = ParameterString(self.MEDIAN, self.tr("Median"), "", False, True)
     median.isAdvanced = True
     self.addParameter(median)
     smooth = ParameterString(self.SMOOTH, self.tr("Smooth"), "", False, True)
     smooth.isAdvanced = True
     self.addParameter(smooth)
     slope = ParameterString(self.SLOPE, self.tr("Slope"), "", False, True)
     slope.isAdvanced = True
     self.addParameter(slope)
     minimum = ParameterBoolean(self.MINIMUM, self.tr("Minimum (set blank if not used)"), False)
     minimum.isAdvanced = True
     self.addParameter(minimum)
     class_var = ParameterString(self.CLASS, self.tr("Class(es)"), 2, False, True)
     class_var.isAdvanced = True
     self.addParameter(class_var)
     advance_modifiers = ParameterString(self.ADVANCED_MODIFIERS, self.tr("Additional modifiers"), "", False, True)
     advance_modifiers.isAdvanced = True
     self.addParameter(advance_modifiers)
Exemplo n.º 3
0
 def testSetValue(self):
     parameter = ParameterBoolean("myName", "myDescription")
     self.assertEqual(parameter.value, None)
     parameter.setValue(False)
     self.assertEqual(parameter.value, False)
     parameter.setValue(True)
     self.assertEqual(parameter.value, True)
Exemplo n.º 4
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm("Canopy Model")
     self.group, self.i18n_group = self.trAlgorithm("Points")
     self.addParameter(ParameterFile(self.INPUT, self.tr("Input LAS layer")))
     self.addParameter(ParameterNumber(self.CELLSIZE, self.tr("Cellsize"), 0, None, 10.0))
     self.addParameter(ParameterSelection(self.XYUNITS, self.tr("XY Units"), self.UNITS))
     self.addParameter(ParameterSelection(self.ZUNITS, self.tr("Z Units"), self.UNITS))
     self.addOutput(OutputFile(self.OUTPUT_DTM, self.tr(".dtm output surface"), "dtm"))
     ground = ParameterFile(self.GROUND, self.tr("Input ground DTM layer"), False, True)
     ground.isAdvanced = True
     self.addParameter(ground)
     median = ParameterString(self.MEDIAN, self.tr("Median"), "", False, True)
     median.isAdvanced = True
     self.addParameter(median)
     smooth = ParameterString(self.SMOOTH, self.tr("Smooth"), "", False, True)
     smooth.isAdvanced = True
     self.addParameter(smooth)
     class_var = ParameterString(self.CLASS, self.tr("Class"), "", False, True)
     class_var.isAdvanced = True
     self.addParameter(class_var)
     slope = ParameterBoolean(self.SLOPE, self.tr("Calculate slope"), False)
     slope.isAdvanced = True
     self.addParameter(slope)
     self.addParameter(ParameterBoolean(self.ASCII, self.tr("Add an ASCII output"), False))
     self.addAdvancedModifiers()
Exemplo n.º 5
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm("Grid Metrics")
        self.group, self.i18n_group = self.trAlgorithm("Points")
        self.addParameter(ParameterFile(self.INPUT, self.tr("Input LAS layer")))
        self.addParameter(ParameterFile(self.GROUND, self.tr("Input ground DTM layer")))
        self.addParameter(ParameterNumber(self.HEIGHT, self.tr("Height break")))
        self.addParameter(ParameterNumber(self.CELLSIZE, self.tr("Cell Size")))

        self.addOutput(OutputFile(self.OUTPUT_CSV_ELEVATION, self.tr("Output table with grid metrics")))

        output_csv_intensity = OutputFile(self.OUTPUT_CSV_INTENSITY, self.tr("OUTPUT CSV INTENSITY"))
        output_csv_intensity.hidden = True
        self.addOutput(output_csv_intensity)

        output_txt_elevation = OutputFile(self.OUTPUT_TXT_ELEVATION, self.tr("OUTPUT CSV INTENSITY"))
        output_txt_elevation.hidden = True
        self.addOutput(output_txt_elevation)

        output_txt_intensity = OutputFile(self.OUTPUT_TXT_INTENSITY, self.tr("OUTPUT CSV INTENSITY"))
        output_txt_intensity.hidden = True
        self.addOutput(output_txt_intensity)

        outlier = ParameterString(self.OUTLIER, self.tr("Outlier:low,high"), "", False, True)
        outlier.isAdvanced = True
        self.addParameter(outlier)
        first = ParameterBoolean(self.FIRST, self.tr("First"), False)
        first.isAdvanced = True
        self.addParameter(first)
        minht = ParameterString(self.MINHT, self.tr("Htmin"), "", False, True)
        minht.isAdvanced = True
        self.addParameter(minht)
        class_var = ParameterString(self.CLASS, self.tr("Class (set blank if not used)"), "", False, True)
        class_var.isAdvanced = True
        self.addParameter(class_var)
Exemplo n.º 6
0
    def testScriptCode(self):
        parameter = ParameterBoolean('myName', 'myDescription')
        code = parameter.getAsScriptCode()
        result = getParameterFromString(code)
        self.assertIsInstance(result, ParameterBoolean)
        self.assertFalse(result.optional)

        parameter.optional = True
        code = parameter.getAsScriptCode()
        result = getParameterFromString(code)
        self.assertIsInstance(result, ParameterBoolean)
        self.assertTrue(result.optional)
Exemplo n.º 7
0
 def defineCharacteristics(self):
     self.name = 'Cloud Metrics'
     self.group = 'Points'
     self.addParameter(ParameterFile(self.INPUT, 'Input las layer'))
     self.addOutput(OutputFile(self.OUTPUT, 'Output file with tabular metric information', 'dtm'))
     above = ParameterString(self.ABOVE, 'Above', '', False)
     above.isAdvanced = True
     self.addParameter(above)
     firstImpulse = ParameterBoolean(self.FIRSTIMPULSE, 'First Impulse', False)
     firstImpulse.isAdvanced = True
     self.addParameter(firstImpulse)
     firstReturn = ParameterBoolean(self.FIRSTRETURN, 'First Return', False)
     firstReturn.isAdvanced = True
     self.addParameter(firstReturn)
     htmin = ParameterString(self.HTMIN, 'Htmin', '', False, True)
     htmin.isAdvanced = True
     self.addParameter(htmin)
Exemplo n.º 8
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm("Clip Data")
     self.group, self.i18n_group = self.trAlgorithm("Points")
     self.addParameter(ParameterFile(self.INPUT, self.tr("Input LAS layer")))
     self.addParameter(ParameterExtent(self.EXTENT, self.tr("Extent"), optional=False))
     self.addParameter(ParameterSelection(self.SHAPE, self.tr("Shape"), ["Rectangle", "Circle"]))
     self.addOutput(OutputFile(self.OUTPUT, self.tr("Output clipped LAS file")))
     dtm = ParameterFile(self.DTM, self.tr("Ground file for height normalization"))
     dtm.isAdvanced = True
     self.addParameter(dtm)
     height = ParameterBoolean(
         self.HEIGHT,
         self.tr("Convert point elevations into heights above ground (used with the above command)"),
         False,
     )
     height.isAdvanced = True
     self.addParameter(height)
     self.addAdvancedModifiers()
Exemplo n.º 9
0
    def defineCharacteristics(self):
        self.name = 'Grid Metrics'
        self.group = 'Points'
        self.addParameter(ParameterFile(
            self.INPUT, self.tr('Input las layer')))
        self.addParameter(ParameterFile(
            self.GROUND, self.tr('Input ground DTM layer')))
        self.addParameter(ParameterNumber(
            self.HEIGHT, self.tr('Height break')))
        self.addParameter(ParameterNumber(
            self.CELLSIZE, self.tr('Cellsize')))

        self.addOutput(OutputFile(
            self.OUTPUT_CSV_ELEVATION, self.tr('Output table with grid metrics')))

        output_csv_intensity = OutputFile(
            self.OUTPUT_CSV_INTENSITY, self.tr('OUTPUT CSV INTENSITY'))
        output_csv_intensity.hidden = True
        self.addOutput(output_csv_intensity)

        output_txt_elevation = OutputFile(
            self.OUTPUT_TXT_ELEVATION, self.tr('OUTPUT CSV INTENSITY'))
        output_txt_elevation.hidden = True
        self.addOutput(output_txt_elevation)

        output_txt_intensity = OutputFile(
            self.OUTPUT_TXT_INTENSITY, self.tr('OUTPUT CSV INTENSITY'))
        output_txt_intensity.hidden = True
        self.addOutput(output_txt_intensity)

        outlier = ParameterString(
            self.OUTLIER, self.tr('Outlier:low,high'), '', False, True)
        outlier.isAdvanced = True
        self.addParameter(outlier)
        first = ParameterBoolean(self.FIRST, self.tr('First'), False)
        first.isAdvanced = True
        self.addParameter(first)
        minht = ParameterString(self.MINHT, self.tr('Htmin'), '', False, True)
        minht.isAdvanced = True
        self.addParameter(minht)
        class_var = ParameterString(
            self.CLASS, self.tr('Class (set blank if not used)'), '', False, True)
        class_var.isAdvanced = True
        self.addParameter(class_var)
Exemplo n.º 10
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm('Clip Data')
     self.group, self.i18n_group = self.trAlgorithm('Points')
     self.addParameter(ParameterFile(
         self.INPUT, self.tr('Input LAS layer')))
     self.addParameter(ParameterExtent(self.EXTENT, self.tr('Extent')))
     self.addParameter(ParameterSelection(
         self.SHAPE, self.tr('Shape'), ['Rectangle', 'Circle']))
     self.addOutput(OutputFile(
         self.OUTPUT, self.tr('Output clipped LAS file')))
     dtm = ParameterFile(
         self.DTM, self.tr('Ground file for height normalization'))
     dtm.isAdvanced = True
     self.addParameter(dtm)
     height = ParameterBoolean(
         self.HEIGHT, self.tr("Convert point elevations into heights above ground (used with the above command)"), False)
     height.isAdvanced = True
     self.addParameter(height)
     self.addAdvancedModifiers()
Exemplo n.º 11
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm('Cloud Metrics')
     self.group, self.i18n_group = self.trAlgorithm('Points')
     self.addParameter(ParameterFile(
         self.INPUT, self.tr('Input LAS layer')))
     self.addOutput(OutputFile(
         self.OUTPUT, self.tr('Output file with tabular metric information'), 'csv'))
     above = ParameterString(self.ABOVE, self.tr('Above'), '', False)
     above.isAdvanced = True
     self.addParameter(above)
     firstImpulse = ParameterBoolean(
         self.FIRSTIMPULSE, self.tr('First Impulse'), False)
     firstImpulse.isAdvanced = True
     self.addParameter(firstImpulse)
     firstReturn = ParameterBoolean(
         self.FIRSTRETURN, self.tr('First Return'), False)
     firstReturn.isAdvanced = True
     self.addParameter(firstReturn)
     htmin = ParameterString(self.HTMIN, self.tr('Htmin'), '', False, True)
     htmin.isAdvanced = True
     self.addParameter(htmin)
Exemplo n.º 12
0
    def testOptional(self):
        optionalParameter = ParameterBoolean("myName", "myDescription", default=False, optional=True)
        self.assertEqual(optionalParameter.value, False)
        optionalParameter.setValue(True)
        self.assertEqual(optionalParameter.value, True)
        self.assertTrue(optionalParameter.setValue(None))
        self.assertEqual(optionalParameter.value, None)

        requiredParameter = ParameterBoolean("myName", "myDescription", default=False, optional=False)
        self.assertEqual(requiredParameter.value, False)
        requiredParameter.setValue(True)
        self.assertEqual(requiredParameter.value, True)
        self.assertFalse(requiredParameter.setValue(None))
        self.assertEqual(requiredParameter.value, True)
Exemplo n.º 13
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm('Canopy Model')
     self.group, self.i18n_group = self.trAlgorithm('Points')
     self.addParameter(ParameterFile(
         self.INPUT, self.tr('Input LAS layer')))
     self.addParameter(ParameterNumber(
         self.CELLSIZE, self.tr('Cell Size'), 0, None, 10.0))
     self.addParameter(ParameterSelection(
         self.XYUNITS, self.tr('XY Units'), self.UNITS))
     self.addParameter(ParameterSelection(
         self.ZUNITS, self.tr('Z Units'), self.UNITS))
     self.addOutput(OutputFile(
         self.OUTPUT_DTM, self.tr('.dtm output surface'), 'dtm'))
     ground = ParameterFile(
         self.GROUND, self.tr('Input ground DTM layer'), False, True)
     ground.isAdvanced = True
     self.addParameter(ground)
     median = ParameterString(
         self.MEDIAN, self.tr('Median'), '', False, True)
     median.isAdvanced = True
     self.addParameter(median)
     smooth = ParameterString(
         self.SMOOTH, self.tr('Smooth'), '', False, True)
     smooth.isAdvanced = True
     self.addParameter(smooth)
     class_var = ParameterString(
         self.CLASS, self.tr('Class'), '', False, True)
     class_var.isAdvanced = True
     self.addParameter(class_var)
     slope = ParameterBoolean(
         self.SLOPE, self.tr('Calculate slope'), False)
     slope.isAdvanced = True
     self.addParameter(slope)
     self.addParameter(ParameterBoolean(
         self.ASCII, self.tr('Add an ASCII output'), False))
     self.addAdvancedModifiers()
Exemplo n.º 14
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm('Import into PostGIS')
     self.group, self.i18n_group = self.trAlgorithm('Database')
     self.addParameter(
         ParameterVector(self.INPUT, self.tr('Layer to import')))
     self.addParameter(
         ParameterString(
             self.DATABASE,
             self.tr('Database (connection name)'),
             metadata={
                 'widget_wrapper': {
                     'class':
                     'processing.gui.wrappers_postgis.ConnectionWidgetWrapper'
                 }
             }))
     self.addParameter(
         ParameterString(
             self.SCHEMA,
             self.tr('Schema (schema name)'),
             'public',
             optional=True,
             metadata={
                 'widget_wrapper': {
                     'class':
                     'processing.gui.wrappers_postgis.SchemaWidgetWrapper',
                     'connection_param': self.DATABASE
                 }
             }))
     self.addParameter(
         ParameterString(
             self.TABLENAME,
             self.tr('Table to import to (leave blank to use layer name)'),
             '',
             optional=True,
             metadata={
                 'widget_wrapper': {
                     'class':
                     'processing.gui.wrappers_postgis.TableWidgetWrapper',
                     'schema_param': self.SCHEMA
                 }
             }))
     self.addParameter(
         ParameterTableField(self.PRIMARY_KEY,
                             self.tr('Primary key field'),
                             self.INPUT,
                             optional=True))
     self.addParameter(
         ParameterString(self.GEOMETRY_COLUMN, self.tr('Geometry column'),
                         'geom'))
     self.addParameter(
         ParameterString(self.ENCODING,
                         self.tr('Encoding'),
                         'UTF-8',
                         optional=True))
     self.addParameter(
         ParameterBoolean(self.OVERWRITE, self.tr('Overwrite'), True))
     self.addParameter(
         ParameterBoolean(self.CREATEINDEX, self.tr('Create spatial index'),
                          True))
     self.addParameter(
         ParameterBoolean(self.LOWERCASE_NAMES,
                          self.tr('Convert field names to lowercase'),
                          True))
     self.addParameter(
         ParameterBoolean(
             self.DROP_STRING_LENGTH,
             self.tr('Drop length constraints on character fields'), False))
     self.addParameter(
         ParameterBoolean(
             self.FORCE_SINGLEPART,
             self.tr('Create single-part geometries instead of multi-part'),
             False))
Exemplo n.º 15
0
 def __init__(self):
     super().__init__()
     self.addParameter(ParameterRaster(self.INPUT, self.tr('Input file')))
     self.addParameter(
         ParameterBoolean(self.PRJ_FILE, self.tr('Create also .prj file'),
                          False))
Exemplo n.º 16
0
 def okPressed(self):
     description = str(self.nameTextBox.text())
     if description.strip() == '':
         QMessageBox.warning(self, self.tr('Unable to define parameter'),
                             self.tr('Invalid parameter name'))
         return
     if self.param is None:
         validChars = \
             'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
         safeName = ''.join(c for c in description if c in validChars)
         name = safeName.lower()
         i = 2
         while name in self.alg.inputs:
             name = safeName.lower() + str(i)
     else:
         name = self.param.name()
     if (self.paramType
             == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN
             or isinstance(self.param, ParameterBoolean)):
         self.param = ParameterBoolean(name, description,
                                       self.state.isChecked())
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD
           or isinstance(self.param, ParameterTableField)):
         if self.parentCombo.currentIndex() < 0:
             QMessageBox.warning(
                 self, self.tr('Unable to define parameter'),
                 self.tr('Wrong or missing parameter values'))
             return
         parent = self.parentCombo.currentData()
         datatype = self.datatypeCombo.currentData()
         self.param = ParameterTableField(
             name,
             description,
             parent,
             datatype,
             multiple=self.multipleCheck.isChecked())
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_RASTER
           or isinstance(self.param, ParameterRaster)):
         self.param = ParameterRaster(name, description)
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_TABLE
           or isinstance(self.param, ParameterTable)):
         self.param = ParameterTable(name, description)
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_VECTOR
           or isinstance(self.param, ParameterVector)):
         self.param = ParameterVector(
             name, description, [self.shapetypeCombo.currentIndex() - 1])
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE
           or isinstance(self.param, ParameterMultipleInput)):
         self.param = ParameterMultipleInput(
             name, description,
             self.datatypeCombo.currentIndex() - 1)
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_NUMBER
           or isinstance(self.param, ParameterNumber)):
         try:
             vmin = self.minTextBox.text().strip()
             if vmin == '':
                 vmin = None
             else:
                 vmin = float(vmin)
             vmax = self.maxTextBox.text().strip()
             if vmax == '':
                 vmax = None
             else:
                 vmax = float(vmax)
             self.param = ParameterNumber(name, description, vmin, vmax,
                                          str(self.defaultTextBox.text()))
         except:
             QMessageBox.warning(
                 self, self.tr('Unable to define parameter'),
                 self.tr('Wrong or missing parameter values'))
             return
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_EXPRESSION
           or isinstance(self.param, ParameterExpression)):
         parent = self.parentCombo.currentData()
         self.param = ParameterExpression(
             name,
             description,
             default=str(self.defaultEdit.expression()),
             parent_layer=parent)
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_STRING
           or isinstance(self.param, ParameterString)):
         self.param = ParameterString(name, description,
                                      str(self.defaultTextBox.text()))
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_EXTENT
           or isinstance(self.param, ParameterExtent)):
         self.param = ParameterExtent(name, description)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE
           or isinstance(self.param, ParameterFile)):
         isFolder = self.fileFolderCombo.currentIndex() == 1
         self.param = ParameterFile(name, description, isFolder=isFolder)
     elif (self.paramType
           == ModelerParameterDefinitionDialog.PARAMETER_POINT
           or isinstance(self.param, ParameterPoint)):
         self.param = ParameterPoint(name, description,
                                     str(self.defaultTextBox.text()))
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_CRS
           or isinstance(self.param, ParameterCrs)):
         self.param = ParameterCrs(name,
                                   description,
                                   default=self.selector.crs().authid())
     if not self.requiredCheck.isChecked():
         self.param.setFlags(
             self.param.flags()
             | QgsProcessingParameterDefinition.FlagOptional)
     self.close()
Exemplo n.º 17
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm(
            'Translate (convert format)')
        self.group, self.i18n_group = self.trAlgorithm('Raster conversion')

        self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer')))
        self.addParameter(
            ParameterNumber(
                self.OUTSIZE,
                self.tr('Set the size of the output file (In pixels or %)'), 1,
                None, 100))
        self.addParameter(
            ParameterBoolean(
                self.OUTSIZE_PERC,
                self.tr('Output size is a percentage of input size'), True))
        self.addParameter(
            ParameterString(
                self.NO_DATA,
                self.
                tr("Nodata value, leave blank to take the nodata value from input"
                   ),
                '',
                optional=True))
        self.addParameter(
            ParameterSelection(self.EXPAND,
                               self.tr('Expand'),
                               ['none', 'gray', 'rgb', 'rgba'],
                               default=0))
        self.addParameter(
            ParameterCrs(
                self.SRS,
                self.
                tr('Output projection for output file [leave blank to use input projection]'
                   ),
                None,
                optional=True))
        self.addParameter(
            ParameterExtent(
                self.PROJWIN,
                self.tr('Subset based on georeferenced coordinates'),
                optional=True))
        self.addParameter(
            ParameterBoolean(
                self.SDS,
                self.
                tr('Copy all subdatasets of this file to individual output files'
                   ), False))

        self.addParameter(
            ParameterString(
                self.OPTIONS,
                self.tr('Additional creation options'),
                optional=True,
                metadata={
                    'widget_wrapper':
                    'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'
                }))
        self.addParameter(
            ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                               self.TYPE, 5))

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Converted')))
Exemplo n.º 18
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm(
            'Rasterize (vector to raster)')
        self.group, self.i18n_group = self.trAlgorithm('[GDAL] Conversion')
        self.addParameter(ParameterVector(self.INPUT, self.tr('Input layer')))
        self.addParameter(
            ParameterTableField(self.FIELD, self.tr('Attribute field'),
                                self.INPUT))
        self.addParameter(
            ParameterSelection(
                self.DIMENSIONS,
                self.
                tr('Set output raster size (ignored if above option is checked)'
                   ), [
                       'Output size in pixels',
                       'Output resolution in map units per pixel'
                   ], 1))
        self.addParameter(
            ParameterNumber(self.WIDTH, self.tr('Horizontal'), 0.0,
                            99999999.999999, 100.0))
        self.addParameter(
            ParameterNumber(self.HEIGHT, self.tr('Vertical'), 0.0,
                            99999999.999999, 100.0))
        self.addParameter(
            ParameterExtent(self.RAST_EXT, self.tr('Raster extent')))

        params = []
        params.append(
            ParameterSelection(self.RTYPE, self.tr('Raster type'), self.TYPE,
                               5))
        params.append(
            ParameterString(self.NO_DATA,
                            self.tr("Nodata value"),
                            '',
                            optional=True))
        params.append(
            ParameterSelection(self.COMPRESS,
                               self.tr('GeoTIFF options. Compression type:'),
                               self.COMPRESSTYPE, 4))
        params.append(
            ParameterNumber(self.JPEGCOMPRESSION,
                            self.tr('Set the JPEG compression level'), 1, 100,
                            75))
        params.append(
            ParameterNumber(self.ZLEVEL,
                            self.tr('Set the DEFLATE compression level'), 1, 9,
                            6))
        params.append(
            ParameterNumber(
                self.PREDICTOR,
                self.tr('Set the predictor for LZW or DEFLATE compression'), 1,
                3, 1))
        params.append(
            ParameterBoolean(
                self.TILED,
                self.tr(
                    'Create tiled output (only used for the GTiff format)'),
                False))
        params.append(
            ParameterSelection(
                self.BIGTIFF,
                self.
                tr('Control whether the created file is a BigTIFF or a classic TIFF'
                   ), self.BIGTIFFTYPE, 0))
        self.addParameter(
            ParameterBoolean(
                self.TFW,
                self.
                tr('Force the generation of an associated ESRI world file (.tfw)'
                   ), False))
        params.append(
            ParameterString(self.EXTRA,
                            self.tr('Additional creation parameters'),
                            '',
                            optional=True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Rasterized')))
Exemplo n.º 19
0
    def processInputParameterToken(self, token, name):
        param = None

        descName = self.createDescriptiveName(name)

        if token.lower().strip() == 'raster':
            param = ParameterRaster(name, descName, False)
        elif token.lower().strip() == 'vector':
            param = ParameterVector(name, descName,
                                    [ParameterVector.VECTOR_TYPE_ANY])
        elif token.lower().strip() == 'vector point':
            param = ParameterVector(name, descName,
                                    [ParameterVector.VECTOR_TYPE_POINT])
        elif token.lower().strip() == 'vector line':
            param = ParameterVector(name, descName,
                                    [ParameterVector.VECTOR_TYPE_LINE])
        elif token.lower().strip() == 'vector polygon':
            param = ParameterVector(name, descName,
                                    [ParameterVector.VECTOR_TYPE_POLYGON])
        elif token.lower().strip() == 'table':
            param = ParameterTable(name, descName, False)
        elif token.lower().strip() == 'multiple raster':
            param = ParameterMultipleInput(name, descName,
                                           ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif token.lower().strip() == 'multiple vector':
            param = ParameterMultipleInput(
                name, descName, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif token.lower().strip().startswith('selectionfromfile'):
            options = token.strip()[len('selectionfromfile '):].split(';')
            param = ParameterSelection(name, descName, options, isSource=True)
        elif token.lower().strip().startswith('selection'):
            options = token.strip()[len('selection '):].split(';')
            param = ParameterSelection(name, descName, options)
        elif token.lower().strip().startswith('boolean'):
            default = token.strip()[len('boolean') + 1:]
            if default:
                param = ParameterBoolean(name, descName, default)
            else:
                param = ParameterBoolean(name, descName)
        elif token.lower().strip() == 'extent':
            param = ParameterExtent(name, descName)
        elif token.lower().strip() == 'file':
            param = ParameterFile(name, descName, False)
        elif token.lower().strip() == 'folder':
            param = ParameterFile(name, descName, True)
        elif token.lower().strip().startswith('number'):
            default = token.strip()[len('number') + 1:]
            if default:
                param = ParameterNumber(name, descName, default=default)
            else:
                param = ParameterNumber(name, descName)
        elif token.lower().strip().startswith('field'):
            field = token.strip()[len('field') + 1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(name, descName, field)
        elif token.lower().strip().startswith('string'):
            default = token.strip()[len('string') + 1:]
            if default:
                param = ParameterString(name, descName, default)
            else:
                param = ParameterString(name, descName)
        elif token.lower().strip().startswith('longstring'):
            default = token.strip()[len('longstring') + 1:]
            if default:
                param = ParameterString(name,
                                        descName,
                                        default,
                                        multiline=True)
            else:
                param = ParameterString(name, descName, multiline=True)
        elif token.lower().strip().startswith('crs'):
            default = token.strip()[len('crs') + 1:]
            if default:
                param = ParameterCrs(name, descName, default)
            else:
                param = ParameterCrs(name, descName)

        return param
Exemplo n.º 20
0
 def okPressed(self):
     description = unicode(self.nameTextBox.text())
     if description.strip() == '':
         QtGui.QMessageBox.warning(self, 'Unable to define parameter',
                              'Invalid parameter name')
         return
     if self.param is None:
         validChars = \
             'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
         safeName = ''.join(c for c in description if c in validChars)
         name = self.paramType.upper().replace(' ', '') + '_' \
             + safeName.upper()
     else:
         name = self.param.name
     if self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN \
             or isinstance(self.param, ParameterBoolean):
         self.param = ParameterBoolean(name, description,
                 self.yesNoCombo.currentIndex() == 0)
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD \
             or isinstance(self.param, ParameterTableField):
         if self.parentCombo.currentIndex() < 0:
             QtGui.QMessageBox.warning(self, 'Unable to define parameter',
                                  'Wrong or missing parameter values')
             return
         parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
         self.param = ParameterTableField(name, description, parent)
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_RASTER \
             or isinstance(self.param, ParameterRaster):
         self.param = ParameterRaster(name, description,
                 self.yesNoCombo.currentIndex() == 1)
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_TABLE \
             or isinstance(self.param, ParameterTable):
         self.param = ParameterTable(name, description,
                 self.yesNoCombo.currentIndex() == 1)
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_VECTOR \
             or isinstance(self.param, ParameterVector):
         self.param = ParameterVector(name, description,
                 [self.shapetypeCombo.currentIndex() - 1],
                 self.yesNoCombo.currentIndex() == 1)
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE \
             or isinstance(self.param, ParameterMultipleInput):
         self.param = ParameterMultipleInput(name, description,
                 self.datatypeCombo.currentIndex() - 1,
                 self.yesNoCombo.currentIndex() == 1)
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_NUMBER \
             or isinstance(self.param, ParameterNumber):
         try:
             vmin = str(self.minTextBox.text()).strip()
             if vmin == '':
                 vmin = None
             else:
                 vmin = float(vmin)
             vmax = str(self.maxTextBox.text()).strip()
             if vmax == '':
                 vmax = None
             else:
                 vmax = float(vmax)
             self.param = ParameterNumber(name, description, vmin, vmax,
                     float(str(self.defaultTextBox.text())))
         except:
             QtGui.QMessageBox.warning(self, 'Unable to define parameter',
                                  'Wrong or missing parameter values')
             return
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_STRING \
             or isinstance(self.param, ParameterString):
         self.param = ParameterString(name, description,
                 unicode(self.defaultTextBox.text()))
     elif self.paramType \
             == ModelerParameterDefinitionDialog.PARAMETER_EXTENT \
             or isinstance(self.param, ParameterExtent):
         self.param = ParameterExtent(name, description)
     elif self.paramType == \
             ModelerParameterDefinitionDialog.PARAMETER_FILE \
             or isinstance(self.param, ParameterFile):
         isFolder = self.fileFolderCombo.currentIndex() == 1
         self.param = ParameterFile(name, description, isFolder=isFolder)
     self.close()
Exemplo n.º 21
0
Arquivo: warp.py Projeto: arx-it/QGIS
    def __init__(self):
        super().__init__()
        self.addParameter(
            ParameterRaster(self.INPUT, self.tr('Input layer'), False))
        self.addParameter(
            ParameterCrs(self.SOURCE_SRS,
                         self.tr('Source SRS'),
                         '',
                         optional=True))
        self.addParameter(
            ParameterCrs(self.DEST_SRS, self.tr('Destination SRS'),
                         'EPSG:4326'))
        self.addParameter(
            ParameterString(
                self.NO_DATA,
                self.
                tr("Nodata value, leave blank to take the nodata value from input"
                   ),
                '',
                optional=True))
        self.addParameter(
            ParameterNumber(
                self.TR,
                self.
                tr('Output file resolution in target georeferenced units (leave 0 for no change)'
                   ), 0.0, None, 0.0))
        self.addParameter(
            ParameterSelection(self.METHOD, self.tr('Resampling method'),
                               self.METHOD_OPTIONS))
        self.addParameter(
            ParameterBoolean(
                self.USE_RASTER_EXTENT,
                self.tr('Set georeferenced extents of output file'), False))
        self.addParameter(
            ParameterExtent(self.RASTER_EXTENT,
                            self.tr('Raster extent'),
                            optional=True))
        self.addParameter(
            ParameterCrs(
                self.EXTENT_CRS,
                self.
                tr('CRS of the raster extent, leave blank for using Destination SRS'
                   ),
                optional=True))
        self.addParameter(
            ParameterString(
                self.OPTIONS,
                self.tr('Additional creation options'),
                optional=True,
                metadata={
                    'widget_wrapper':
                    'processing.algs.gdal.ui.RasterOptionsWidget.RasterOptionsWidgetWrapper'
                }))
        self.addParameter(
            ParameterBoolean(
                self.MULTITHREADING,
                self.tr('Use multithreaded warping implementation'), False))
        self.addParameter(
            ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                               self.TYPE, 5))

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Reprojected')))
Exemplo n.º 22
0
    def processParameterLine(self, line):
        param = None
        out = None
        line = line.replace('#', '')
        if line.lower().strip().startswith('showplots'):
            self.showPlots = True
            self.addOutput(OutputHTML(RAlgorithm.RPLOTS, 'R Plots'))
            return
        if line.lower().strip().startswith('dontuserasterpackage'):
            self.useRasterPackage = False
            return
        if line.lower().strip().startswith('passfilenames'):
            self.passFileNames = True
            return
        tokens = line.split('=')
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == 'group':
            self.group = tokens[0]
            return
        if tokens[1].lower().strip().startswith('raster'):
            param = ParameterRaster(tokens[0], desc, False)
        elif tokens[1].lower().strip() == 'vector':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_ANY])
        elif tokens[1].lower().strip() == 'vector point':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_POINT])
        elif tokens[1].lower().strip() == 'vector line':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_LINE])
        elif tokens[1].lower().strip() == 'vector polygon':
            param = ParameterVector(tokens[0], desc,
                                    [ParameterVector.VECTOR_TYPE_POLYGON])
        elif tokens[1].lower().strip() == 'table':
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip().startswith('multiple raster'):
            param = ParameterMultipleInput(tokens[0], desc,
                                           ParameterMultipleInput.TYPE_RASTER)
            param.optional = False
        elif tokens[1].lower().strip() == 'multiple vector':
            param = ParameterMultipleInput(
                tokens[0], desc, ParameterMultipleInput.TYPE_VECTOR_ANY)
            param.optional = False
        elif tokens[1].lower().strip().startswith('selection'):
            options = tokens[1].strip()[len('selection'):].split(';')
            param = ParameterSelection(tokens[0], desc, options)
        elif tokens[1].lower().strip().startswith('boolean'):
            default = tokens[1].strip()[len('boolean') + 1:]
            param = ParameterBoolean(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith('number'):
            try:
                default = float(tokens[1].strip()[len('number') + 1:])
                param = ParameterNumber(tokens[0], desc, default=default)
            except:
                raise WrongScriptException(
                    self.tr(
                        'Could not load R script: %s.\n Problem with line %s' %
                        (self.descriptionFile, line)))
        elif tokens[1].lower().strip().startswith('field'):
            field = tokens[1].strip()[len('field') + 1:]
            found = False
            for p in self.parameters:
                if p.name == field:
                    found = True
                    break
            if found:
                param = ParameterTableField(tokens[0], tokens[0], field)
        elif tokens[1].lower().strip() == 'extent':
            param = ParameterExtent(tokens[0], desc)
        elif tokens[1].lower().strip() == 'file':
            param = ParameterFile(tokens[0], desc, False)
        elif tokens[1].lower().strip() == 'folder':
            param = ParameterFile(tokens[0], desc, True)
        elif tokens[1].lower().strip().startswith('string'):
            default = tokens[1].strip()[len('string') + 1:]
            param = ParameterString(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith('longstring'):
            default = tokens[1].strip()[len('longstring') + 1:]
            param = ParameterString(tokens[0], desc, default, multiline=True)
        elif tokens[1].lower().strip().startswith('output raster'):
            out = OutputRaster()
        elif tokens[1].lower().strip().startswith('output vector'):
            out = OutputVector()
        elif tokens[1].lower().strip().startswith('output table'):
            out = OutputTable()
        elif tokens[1].lower().strip().startswith('output file'):
            out = OutputFile()

        if param is not None:
            self.addParameter(param)
        elif out is not None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException(
                self.tr('Could not load R script: %s.\n Problem with line %s' %
                        (self.descriptionFile, line)))
Exemplo n.º 23
0
 def __init__(self):
     super().__init__()
     self.DB_CONNECTIONS = self.dbConnectionNames()
     self.addParameter(
         ParameterSelection(self.DATABASE,
                            self.tr('Database (connection name)'),
                            self.DB_CONNECTIONS))
     self.addParameter(
         ParameterTable(self.INPUT_LAYER, self.tr('Input layer')))
     self.addParameter(
         ParameterString(self.SHAPE_ENCODING,
                         self.tr('Shape encoding'),
                         "",
                         optional=True))
     self.addParameter(
         ParameterString(self.SCHEMA,
                         self.tr('Schema name'),
                         'public',
                         optional=True))
     self.addParameter(
         ParameterString(
             self.TABLE,
             self.tr('Table name, leave blank to use input name'),
             '',
             optional=True))
     self.addParameter(
         ParameterString(self.PK,
                         self.tr('Primary key'),
                         'id',
                         optional=True))
     self.addParameter(
         ParameterTableField(
             self.PRIMARY_KEY,
             self.
             tr('Primary key (existing field, used if the above option is left empty)'
                ),
             self.INPUT_LAYER,
             optional=True))
     self.addParameter(
         ParameterString(
             self.WHERE,
             self.
             tr('Select features using a SQL "WHERE" statement (Ex: column=\'value\')'
                ),
             '',
             optional=True))
     self.addParameter(
         ParameterString(
             self.GT,
             self.tr('Group N features per transaction (Default: 20000)'),
             '',
             optional=True))
     self.addParameter(
         ParameterBoolean(self.OVERWRITE,
                          self.tr('Overwrite existing table'), True))
     self.addParameter(
         ParameterBoolean(self.APPEND, self.tr('Append to existing table'),
                          False))
     self.addParameter(
         ParameterBoolean(
             self.ADDFIELDS,
             self.tr('Append and add new fields to existing table'), False))
     self.addParameter(
         ParameterBoolean(self.LAUNDER,
                          self.tr('Do not launder columns/table names'),
                          False))
     self.addParameter(
         ParameterBoolean(
             self.SKIPFAILURES,
             self.tr(
                 'Continue after a failure, skipping the failed record'),
             False))
     self.addParameter(
         ParameterBoolean(
             self.PRECISION,
             self.tr('Keep width and precision of input attributes'), True))
     self.addParameter(
         ParameterString(self.OPTIONS,
                         self.tr('Additional creation options'),
                         '',
                         optional=True))
Exemplo n.º 24
0
 def __init__(self):
     super().__init__()
     self.addParameter(
         ParameterVector(self.INPUT_LAYER, self.tr('Input layer')))
     self.addParameter(
         ParameterString(self.SHAPE_ENCODING,
                         self.tr('Shape encoding'),
                         "",
                         optional=True))
     self.addParameter(
         ParameterSelection(self.GTYPE, self.tr('Output geometry type'),
                            self.GEOMTYPE, 0))
     self.addParameter(
         ParameterCrs(self.A_SRS,
                      self.tr('Assign an output CRS'),
                      '',
                      optional=False))
     self.addParameter(
         ParameterCrs(self.T_SRS,
                      self.tr('Reproject to this CRS on output '),
                      '',
                      optional=True))
     self.addParameter(
         ParameterCrs(self.S_SRS,
                      self.tr('Override source CRS'),
                      '',
                      optional=True))
     self.addParameter(
         ParameterString(self.HOST,
                         self.tr('Host'),
                         'localhost',
                         optional=True))
     self.addParameter(
         ParameterString(self.PORT, self.tr('Port'), '5432', optional=True))
     self.addParameter(
         ParameterString(self.USER, self.tr('Username'), '', optional=True))
     self.addParameter(
         ParameterString(self.DBNAME,
                         self.tr('Database name'),
                         '',
                         optional=True))
     self.addParameter(
         ParameterString(self.PASSWORD,
                         self.tr('Password'),
                         '',
                         optional=True))
     self.addParameter(
         ParameterString(self.SCHEMA,
                         self.tr('Schema name'),
                         'public',
                         optional=True))
     self.addParameter(
         ParameterString(
             self.TABLE,
             self.tr('Table name, leave blank to use input name'),
             '',
             optional=True))
     self.addParameter(
         ParameterString(self.PK,
                         self.tr('Primary key (new field)'),
                         'id',
                         optional=True))
     self.addParameter(
         ParameterTableField(
             self.PRIMARY_KEY,
             self.
             tr('Primary key (existing field, used if the above option is left empty)'
                ),
             self.INPUT_LAYER,
             optional=True))
     self.addParameter(
         ParameterString(self.GEOCOLUMN,
                         self.tr('Geometry column name'),
                         'geom',
                         optional=True))
     self.addParameter(
         ParameterSelection(self.DIM, self.tr('Vector dimensions'),
                            self.DIMLIST, 0))
     self.addParameter(
         ParameterString(self.SIMPLIFY,
                         self.tr('Distance tolerance for simplification'),
                         '',
                         optional=True))
     self.addParameter(
         ParameterString(
             self.SEGMENTIZE,
             self.tr('Maximum distance between 2 nodes (densification)'),
             '',
             optional=True))
     self.addParameter(
         ParameterExtent(
             self.SPAT,
             self.tr(
                 'Select features by extent (defined in input layer CRS)')))
     self.addParameter(
         ParameterBoolean(
             self.CLIP,
             self.tr(
                 'Clip the input layer using the above (rectangle) extent'),
             False))
     self.addParameter(
         ParameterString(
             self.WHERE,
             self.
             tr('Select features using a SQL "WHERE" statement (Ex: column=\'value\')'
                ),
             '',
             optional=True))
     self.addParameter(
         ParameterString(
             self.GT,
             self.tr('Group N features per transaction (Default: 20000)'),
             '',
             optional=True))
     self.addParameter(
         ParameterBoolean(self.OVERWRITE,
                          self.tr('Overwrite existing table'), True))
     self.addParameter(
         ParameterBoolean(self.APPEND, self.tr('Append to existing table'),
                          False))
     self.addParameter(
         ParameterBoolean(
             self.ADDFIELDS,
             self.tr('Append and add new fields to existing table'), False))
     self.addParameter(
         ParameterBoolean(self.LAUNDER,
                          self.tr('Do not launder columns/table names'),
                          False))
     self.addParameter(
         ParameterBoolean(self.INDEX,
                          self.tr('Do not create spatial index'), False))
     self.addParameter(
         ParameterBoolean(
             self.SKIPFAILURES,
             self.tr(
                 'Continue after a failure, skipping the failed feature'),
             False))
     self.addParameter(
         ParameterBoolean(self.PROMOTETOMULTI,
                          self.tr('Promote to Multipart'), True))
     self.addParameter(
         ParameterBoolean(
             self.PRECISION,
             self.tr('Keep width and precision of input attributes'), True))
     self.addParameter(
         ParameterString(self.OPTIONS,
                         self.tr('Additional creation options'),
                         '',
                         optional=True))
Exemplo n.º 25
0
 def defineCharacteristics(self):
     self.addParameter(ParameterRaster(self.INPUT, self.tr('Input file')))
     self.addParameter(
         ParameterBoolean(self.PRJ_FILE, self.tr('Create also .prj file'),
                          False))
Exemplo n.º 26
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm(
            'Translate (convert format)')
        self.group, self.i18n_group = self.trAlgorithm('[GDAL] Conversion')
        self.addParameter(
            ParameterRaster(self.INPUT, self.tr('Input layer'), False))
        self.addParameter(
            ParameterNumber(
                self.OUTSIZE,
                self.tr('Set the size of the output file (In pixels or %)'), 1,
                None, 100))
        self.addParameter(
            ParameterBoolean(
                self.OUTSIZE_PERC,
                self.tr('Output size is a percentage of input size'), True))
        self.addParameter(
            ParameterString(
                self.NO_DATA,
                self.
                tr("Nodata value, leave blank to take the nodata value from input"
                   ),
                '',
                optional=True))
        self.addParameter(
            ParameterSelection(self.EXPAND, self.tr('Expand'),
                               ['none', 'gray', 'rgb', 'rgba']))
        self.addParameter(
            ParameterCrs(
                self.SRS,
                self.
                tr('Output projection for output file [leave blank to use input projection]'
                   ),
                None,
                optional=True))
        self.addParameter(
            ParameterExtent(
                self.PROJWIN,
                self.tr('Subset based on georeferenced coordinates')))
        self.addParameter(
            ParameterBoolean(
                self.SDS,
                self.
                tr('Copy all subdatasets of this file to individual output files'
                   ), False))

        params = []
        params.append(
            ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                               self.TYPE, 5))
        params.append(
            ParameterSelection(self.COMPRESS,
                               self.tr('GeoTIFF options. Compression type:'),
                               self.COMPRESSTYPE, 4))
        params.append(
            ParameterNumber(self.JPEGCOMPRESSION,
                            self.tr('Set the JPEG compression level'), 1, 100,
                            75))
        params.append(
            ParameterNumber(self.ZLEVEL,
                            self.tr('Set the DEFLATE compression level'), 1, 9,
                            6))
        params.append(
            ParameterNumber(
                self.PREDICTOR,
                self.tr('Set the predictor for LZW or DEFLATE compression'), 1,
                3, 1))
        params.append(
            ParameterBoolean(
                self.TILED,
                self.tr(
                    'Create tiled output (only used for the GTiff format)'),
                False))
        params.append(
            ParameterSelection(
                self.BIGTIFF,
                self.
                tr('Control whether the created file is a BigTIFF or a classic TIFF'
                   ), self.BIGTIFFTYPE, 0))
        params.append(
            ParameterBoolean(
                self.TFW,
                self.
                tr('Force the generation of an associated ESRI world file (.tfw))'
                   ), False))
        params.append(
            ParameterString(self.EXTRA,
                            self.tr('Additional creation parameters'),
                            '',
                            optional=True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Converted')))
Exemplo n.º 27
0
    def defineCharacteristics(self):
        # Required parameters
        self.addParameter(
            ParameterMultipleInput(self.INPUT, self.tr('Input layers'),
                                   dataobjects.TYPE_RASTER))
        # Advanced parameters
        params = []
        params.append(
            ParameterString(
                self.PIXELSIZE,
                self.
                tr('Pixel size to be used for the output file (XSIZE YSIZE like 512 512)'
                   ), None, False, True))
        params.append(
            ParameterSelection(self.ALGORITHM,
                               self.tr('Resampling algorithm'),
                               self.ALGO,
                               0,
                               False,
                               optional=True))
        params.append(
            ParameterCrs(self.S_SRS, self.tr('Override source CRS'), None,
                         True))
        params.append(
            ParameterNumber(self.PYRAMIDLEVELS,
                            self.tr('Number of pyramids levels to build'),
                            None, None, None, True))
        params.append(
            ParameterBoolean(self.ONLYPYRAMIDS,
                             self.tr('Build only the pyramids'), False, True))
        params.append(
            ParameterSelection(self.RTYPE,
                               self.tr('Output raster type'),
                               self.TYPE,
                               5,
                               False,
                               optional=True))
        params.append(
            ParameterSelection(self.FORMAT,
                               self.tr('Output raster format'),
                               list(GdalUtils.getSupportedRasters().keys()),
                               0,
                               False,
                               optional=True))
        params.append(
            ParameterBoolean(self.USEDIRFOREACHROW,
                             self.tr('Use a directory for each row'), False,
                             True))
        params.append(
            ParameterString(
                self.CSVFILE,
                self.
                tr('Name of the csv file containing the tile(s) georeferencing information'
                   ), None, False, True))
        params.append(
            ParameterString(self.CSVDELIM,
                            self.tr('Column delimiter used in the CSV file'),
                            None, False, True))
        params.append(
            ParameterString(
                self.TILEINDEX,
                self.tr(
                    'name of shape file containing the result tile(s) index'),
                None, False, True))
        params.append(
            ParameterString(
                self.TILEINDEXFIELD,
                self.
                tr('name of the attribute containing the tile name in the result shape file'
                   ), None, False, True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(
            OutputDirectory(
                self.TARGETDIR,
                self.tr('The directory where the tile result is created')))
Exemplo n.º 28
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm(
         'SLMS - Import Vector timeseries instance into PostGIS (APPEND MODE)'
     )
     self.group, self.i18n_group = self.trAlgorithm('[OGR] Miscellaneous')
     self.DB_CONNECTIONS = self.dbConnectionNames()
     self.addParameter(
         ParameterSelection(self.DATABASE,
                            self.tr('Database (connection name)'),
                            self.DB_CONNECTIONS))
     self.addParameter(
         ParameterVector(self.INPUT_LAYER, self.tr('Input layer'),
                         [ParameterVector.VECTOR_TYPE_ANY], False))
     #self.addParameter(ParameterSelection(self.GTYPE,
     #                                     self.tr('Output geometry type'), self.GEOMTYPE, 0))
     #self.addParameter(ParameterCrs(self.A_SRS,
     #                               self.tr('Assign an output CRS'), '', optional=True))
     self.addParameter(
         ParameterCrs(self.T_SRS,
                      self.tr('Reproject to this CRS on output '),
                      '',
                      optional=True))
     #self.addParameter(ParameterCrs(self.S_SRS,
     #                               self.tr('Override source CRS'), '', optional=True))
     self.addParameter(
         ParameterString(self.SCHEMA, self.tr('Schema name'),
                         'stg_geoserver'))
     self.addParameter(
         ParameterString(self.TABLE,
                         self.tr('The output PostGIS table name'), False))
     self.addParameter(
         ParameterString(self.PK,
                         self.tr('Primary key (new field)'),
                         'id',
                         optional=True))
     self.addParameter(
         ParameterTableField(
             self.PRIMARY_KEY,
             self.
             tr('Primary key (existing field, used if the above option is left empty)'
                ),
             self.INPUT_LAYER,
             optional=True))
     self.addParameter(
         ParameterString(self.GEOCOLUMN,
                         self.tr('Geometry column name'),
                         'the_geom',
                         optional=True))
     #self.addParameter(ParameterSelection(self.DIM,
     #                                     self.tr('Vector dimensions'), self.DIMLIST, 0))
     #self.addParameter(ParameterString(self.SIMPLIFY,
     #                                  self.tr('Distance tolerance for simplification'),
     #                                  '', optional=True))
     #self.addParameter(ParameterString(self.SEGMENTIZE,
     #                                  self.tr('Maximum distance between 2 nodes (densification)'),
     #                                  '', optional=True))
     #self.addParameter(ParameterExtent(self.SPAT,
     #                                  self.tr('Select features by extent (defined in input layer CRS)')))
     #self.addParameter(ParameterBoolean(self.CLIP,
     #                                   self.tr('Clip the input layer using the above (rectangle) extent'),
     #                                   False))
     #self.addParameter(ParameterString(self.WHERE,
     #                                  self.tr('Select features using a SQL "WHERE" statement (Ex: column=\'value\')'),
     #                                  '', optional=True))
     #self.addParameter(ParameterString(self.GT,
     #                                  self.tr('Group N features per transaction (Default: 20000)'),
     #                                  '', optional=True))
     #self.addParameter(ParameterBoolean(self.OVERWRITE,
     #                                   self.tr('Overwrite existing table'), True))
     #self.addParameter(ParameterBoolean(self.APPEND,
     #                                   self.tr('Append to existing table'), False))
     #self.addParameter(ParameterBoolean(self.ADDFIELDS,
     #                                   self.tr('Append and add new fields to existing table'), False))
     #self.addParameter(ParameterBoolean(self.LAUNDER,
     #                                   self.tr('Do not launder columns/table names'), False))
     #self.addParameter(ParameterBoolean(self.INDEX,
     #                                   self.tr('Do not create spatial index'), False))
     self.addParameter(
         ParameterBoolean(
             self.SKIPFAILURES,
             self.tr(
                 'Continue after a failure, skipping the failed feature'),
             False))
Exemplo n.º 29
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm(
         'Import Vector into PostGIS database (available connections)')
     self.group, self.i18n_group = self.trAlgorithm('[OGR] Miscellaneous')
     self.addParameter(
         ParameterString(
             self.DATABASE,
             self.tr('Database (connection name)'),
             metadata={
                 'widget_wrapper': {
                     'class':
                     'processing.gui.wrappers_postgis.ConnectionWidgetWrapper'
                 }
             }))
     self.addParameter(
         ParameterVector(self.INPUT_LAYER, self.tr('Input layer')))
     self.addParameter(
         ParameterString(self.SHAPE_ENCODING,
                         self.tr('Shape encoding'),
                         "",
                         optional=True))
     self.addParameter(
         ParameterSelection(self.GTYPE, self.tr('Output geometry type'),
                            self.GEOMTYPE, 0))
     self.addParameter(
         ParameterCrs(self.A_SRS,
                      self.tr('Assign an output CRS'),
                      '',
                      optional=False))
     self.addParameter(
         ParameterCrs(self.T_SRS,
                      self.tr('Reproject to this CRS on output '),
                      '',
                      optional=True))
     self.addParameter(
         ParameterCrs(self.S_SRS,
                      self.tr('Override source CRS'),
                      '',
                      optional=True))
     self.addParameter(
         ParameterString(
             self.SCHEMA,
             self.tr('Schema name'),
             'public',
             optional=True,
             metadata={
                 'widget_wrapper': {
                     'class':
                     'processing.gui.wrappers_postgis.SchemaWidgetWrapper',
                     'connection_param': self.DATABASE
                 }
             }))
     self.addParameter(
         ParameterString(
             self.TABLE,
             self.tr('Table name, leave blank to use input name'),
             '',
             optional=True,
             metadata={
                 'widget_wrapper': {
                     'class':
                     'processing.gui.wrappers_postgis.TableWidgetWrapper',
                     'schema_param': self.SCHEMA
                 }
             }))
     self.addParameter(
         ParameterString(self.PK,
                         self.tr('Primary key (new field)'),
                         'id',
                         optional=True))
     self.addParameter(
         ParameterTableField(
             self.PRIMARY_KEY,
             self.
             tr('Primary key (existing field, used if the above option is left empty)'
                ),
             self.INPUT_LAYER,
             optional=True))
     self.addParameter(
         ParameterString(self.GEOCOLUMN,
                         self.tr('Geometry column name'),
                         'geom',
                         optional=True))
     self.addParameter(
         ParameterSelection(self.DIM, self.tr('Vector dimensions'),
                            self.DIMLIST, 0))
     self.addParameter(
         ParameterString(self.SIMPLIFY,
                         self.tr('Distance tolerance for simplification'),
                         '',
                         optional=True))
     self.addParameter(
         ParameterString(
             self.SEGMENTIZE,
             self.tr('Maximum distance between 2 nodes (densification)'),
             '',
             optional=True))
     self.addParameter(
         ParameterExtent(
             self.SPAT,
             self.tr(
                 'Select features by extent (defined in input layer CRS)')))
     self.addParameter(
         ParameterBoolean(
             self.CLIP,
             self.tr(
                 'Clip the input layer using the above (rectangle) extent'),
             False))
     self.addParameter(
         ParameterString(
             self.WHERE,
             self.
             tr('Select features using a SQL "WHERE" statement (Ex: column=\'value\')'
                ),
             '',
             optional=True))
     self.addParameter(
         ParameterString(
             self.GT,
             self.tr('Group N features per transaction (Default: 20000)'),
             '',
             optional=True))
     self.addParameter(
         ParameterBoolean(self.OVERWRITE,
                          self.tr('Overwrite existing table'), True))
     self.addParameter(
         ParameterBoolean(self.APPEND, self.tr('Append to existing table'),
                          False))
     self.addParameter(
         ParameterBoolean(
             self.ADDFIELDS,
             self.tr('Append and add new fields to existing table'), False))
     self.addParameter(
         ParameterBoolean(self.LAUNDER,
                          self.tr('Do not launder columns/table names'),
                          False))
     self.addParameter(
         ParameterBoolean(self.INDEX,
                          self.tr('Do not create spatial index'), False))
     self.addParameter(
         ParameterBoolean(
             self.SKIPFAILURES,
             self.tr(
                 'Continue after a failure, skipping the failed feature'),
             False))
     self.addParameter(
         ParameterBoolean(self.PROMOTETOMULTI,
                          self.tr('Promote to Multipart'), True))
     self.addParameter(
         ParameterBoolean(
             self.PRECISION,
             self.tr('Keep width and precision of input attributes'), True))
     self.addParameter(
         ParameterString(self.OPTIONS,
                         self.tr('Additional creation options'),
                         '',
                         optional=True))
Exemplo n.º 30
0
 def addParametersPointInputMergedGUI(self):
     self.addParameter(
         ParameterBoolean(
             LAStoolsAlgorithm.MERGED,
             self.tr("merge all input files on-the-fly into one"), False))
Exemplo n.º 31
0
 def initAlgorithm(self, config=None):
     self.addParameter(ParameterRaster(self.INPUT, self.tr('Input file')))
     self.addParameter(
         ParameterBoolean(self.PRJ_FILE, self.tr('Create also .prj file'),
                          False))
Exemplo n.º 32
0
 def defineCharacteristics(self):
     self.name, self.i18n_name = self.trAlgorithm('Extract projection')
     self.group, self.i18n_group = self.trAlgorithm('[GDAL] Projections')
     self.addParameter(ParameterRaster(self.INPUT, self.tr('Input file')))
     self.addParameter(ParameterBoolean(self.PRJ_FILE,
                                        self.tr('Create also .prj file'), False))
Exemplo n.º 33
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm('Clip raster by extent')
        self.group, self.i18n_group = self.trAlgorithm('[GDAL] Extraction')
        self.addParameter(
            ParameterRaster(self.INPUT, self.tr('Input layer'), False))
        self.addParameter(
            ParameterString(
                self.NO_DATA,
                self.
                tr("Nodata value, leave blank to take the nodata value from input"
                   ),
                '',
                optional=True))
        self.addParameter(
            ParameterExtent(self.PROJWIN, self.tr('Clipping extent')))

        params = []
        params.append(
            ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                               self.TYPE, 5))
        params.append(
            ParameterSelection(self.COMPRESS,
                               self.tr('GeoTIFF options. Compression type:'),
                               self.COMPRESSTYPE, 4))
        params.append(
            ParameterNumber(self.JPEGCOMPRESSION,
                            self.tr('Set the JPEG compression level'), 1, 100,
                            75))
        params.append(
            ParameterNumber(self.ZLEVEL,
                            self.tr('Set the DEFLATE compression level'), 1, 9,
                            6))
        params.append(
            ParameterNumber(
                self.PREDICTOR,
                self.tr('Set the predictor for LZW or DEFLATE compression'), 1,
                3, 1))
        params.append(
            ParameterBoolean(
                self.TILED,
                self.tr(
                    'Create tiled output (only used for the GTiff format)'),
                False))
        params.append(
            ParameterSelection(
                self.BIGTIFF,
                self.
                tr('Control whether the created file is a BigTIFF or a classic TIFF'
                   ), self.BIGTIFFTYPE, 0))
        params.append(
            ParameterBoolean(
                self.TFW,
                self.
                tr('Force the generation of an associated ESRI world file (.tfw))'
                   ), False))
        params.append(
            ParameterString(self.EXTRA,
                            self.tr('Additional creation parameters'),
                            '',
                            optional=True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Clipped (extent)')))
Exemplo n.º 34
0
 def addParametersVerticalFeetGUI(self):
     self.addParameter(
         ParameterBoolean(LAStoolsAlgorithm.VERTICAL_FEET,
                          self.tr("vertical feet"), False))
Exemplo n.º 35
0
 def testDefault(self):
     parameter = ParameterBoolean('myName', 'myDescription', default=False, optional=True)
     self.assertEqual(parameter.value, False)
     parameter.setValue(None)
     self.assertEqual(parameter.value, None)
Exemplo n.º 36
0
 def addParametersFilesAreFlightlinesGUI(self):
     self.addParameter(
         ParameterBoolean(LAStoolsAlgorithm.FILES_ARE_FLIGHTLINES,
                          self.tr("files are flightlines"), False))
Exemplo n.º 37
0
    def __init__(self):
        super().__init__()

        class ParameterReliefColors(Parameter):
            default_metadata = {
                'widget_wrapper':
                'processing.algs.qgis.ui.ReliefColorsWidget.ReliefColorsWidgetWrapper'
            }

            def __init__(self,
                         name='',
                         description='',
                         parent=None,
                         optional=True):
                Parameter.__init__(self, name, description, None, optional)
                self.parent = parent

            def setValue(self, value):
                if value is None:
                    if not self.flags(
                    ) & QgsProcessingParameterDefinition.FlagOptional:
                        return False
                    self.value = None
                    return True

                if value == '':
                    if not self.flags(
                    ) & QgsProcessingParameterDefinition.FlagOptional:
                        return False

                if isinstance(value, str):
                    self.value = value if value != '' else None
                else:
                    self.value = ParameterReliefColors.colorsToString(value)
                return True

            def getValueAsCommandLineParameter(self):
                return '"{}"'.format(self.value)

            def getAsScriptCode(self):
                param_type = ''
                param_type += 'relief colors '
                return '##' + self.name + '=' + param_type

            @classmethod
            def fromScriptCode(self, line):
                isOptional, name, definition = _splitParameterOptions(line)
                descName = _createDescriptiveName(name)
                parent = definition.lower().strip()[len('relief colors') + 1:]
                return ParameterReliefColors(name, descName, parent)

            @staticmethod
            def colorsToString(colors):
                s = ''
                for c in colors:
                    s += '{:f}, {:f}, {:d}, {:d}, {:d};'.format(
                        c[0], c[1], c[2], c[3], c[4])
                return s[:-1]

        self.addParameter(
            ParameterRaster(self.INPUT_LAYER, self.tr('Elevation layer')))
        self.addParameter(
            ParameterNumber(self.Z_FACTOR, self.tr('Z factor'), 1.0, 999999.99,
                            1.0))
        self.addParameter(
            ParameterBoolean(self.AUTO_COLORS,
                             self.tr('Generate relief classes automatically'),
                             False))
        self.addParameter(
            ParameterReliefColors(self.COLORS, self.tr('Relief colors'),
                                  self.INPUT_LAYER, True))
        self.addOutput(OutputRaster(self.OUTPUT_LAYER, self.tr('Relief')))
        self.addOutput(
            OutputTable(self.FREQUENCY_DISTRIBUTION,
                        self.tr('Frequency distribution')))
Exemplo n.º 38
0
 def addParametersApplyFileSourceIdGUI(self):
     self.addParameter(
         ParameterBoolean(LAStoolsAlgorithm.APPLY_FILE_SOURCE_ID,
                          self.tr("apply file source ID"), False))
Exemplo n.º 39
0
 def testDefault(self):
     parameter = ParameterBoolean("myName", "myDescription", default=False, optional=True)
     self.assertEqual(parameter.value, False)
     parameter.setValue(None)
     self.assertEqual(parameter.value, None)
Exemplo n.º 40
0
 def defineCharacteristics(self):
     self.name = 'Warp (reproject)'
     self.group = '[GDAL] Projections'
     self.addParameter(
         ParameterRaster(self.INPUT, self.tr('Input layer'), False))
     self.addParameter(
         ParameterCrs(self.SOURCE_SRS, self.tr('Source SRS'), ''))
     self.addParameter(
         ParameterCrs(self.DEST_SRS, self.tr('Destination SRS'), ''))
     self.addParameter(
         ParameterString(
             self.NO_DATA,
             self.
             tr("Nodata value, leave blank to take the nodata value from input"
                ), '-9999'))
     self.addParameter(
         ParameterNumber(
             self.TR,
             self.
             tr('Output file resolution in target georeferenced units (leave 0 for no change)'
                ), 0.0, None, 0.0))
     self.addParameter(
         ParameterSelection(self.METHOD, self.tr('Resampling method'),
                            self.METHOD_OPTIONS))
     self.addParameter(
         ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                            self.TYPE, 5))
     self.addParameter(
         ParameterSelection(self.COMPRESS,
                            self.tr('GeoTIFF options. Compression type:'),
                            self.COMPRESSTYPE, 4))
     self.addParameter(
         ParameterNumber(self.JPEGCOMPRESSION,
                         self.tr('Set the JPEG compression level'), 1, 100,
                         75))
     self.addParameter(
         ParameterNumber(self.ZLEVEL,
                         self.tr('Set the DEFLATE compression level'), 1, 9,
                         6))
     self.addParameter(
         ParameterNumber(
             self.PREDICTOR,
             self.tr('Set the predictor for LZW or DEFLATE compression'), 1,
             3, 1))
     self.addParameter(
         ParameterBoolean(
             self.TILED,
             self.tr(
                 'Create tiled output (only used for the GTiff format)'),
             False))
     self.addParameter(
         ParameterSelection(
             self.BIGTIFF,
             self.
             tr('Control whether the created file is a BigTIFF or a classic TIFF'
                ), self.BIGTIFFTYPE, 0))
     self.addParameter(
         ParameterBoolean(
             self.TFW,
             self.
             tr('Force the generation of an associated ESRI world file (.tfw))'
                ), False))
     self.addParameter(
         ParameterString(self.EXTRA,
                         self.tr('Additional creation parameters'),
                         '',
                         optional=True))
     self.addOutput(OutputRaster(self.OUTPUT, self.tr('Reprojected')))
Exemplo n.º 41
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm('Warp (reproject)')
        self.group, self.i18n_group = self.trAlgorithm('[GDAL] Projections')
        self.tags = self.tr('transform,reproject,crs,srs')
        self.addParameter(
            ParameterRaster(self.INPUT, self.tr('Input layer'), False))
        self.addParameter(
            ParameterCrs(self.SOURCE_SRS,
                         self.tr('Source SRS'),
                         '',
                         optional=True))
        self.addParameter(
            ParameterCrs(self.DEST_SRS, self.tr('Destination SRS'),
                         'EPSG:4326'))
        self.addParameter(
            ParameterString(
                self.NO_DATA,
                self.
                tr("Nodata value, leave blank to take the nodata value from input"
                   ),
                '',
                optional=True))
        self.addParameter(
            ParameterNumber(
                self.TR,
                self.
                tr('Output file resolution in target georeferenced units (leave 0 for no change)'
                   ), 0.0, None, 0.0))
        self.addParameter(
            ParameterSelection(self.METHOD, self.tr('Resampling method'),
                               self.METHOD_OPTIONS))
        self.addParameter(
            ParameterExtent(self.RAST_EXT,
                            self.tr('Raster extent'),
                            optional=True))

        if GdalUtils.version() >= 2000000:
            self.addParameter(
                ParameterCrs(
                    self.EXT_CRS,
                    self.
                    tr('CRS of the raster extent, leave blank for using Destination SRS'
                       ),
                    optional=True))

        params = []
        params.append(
            ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                               self.TYPE, 5))
        params.append(
            ParameterSelection(self.COMPRESS,
                               self.tr('GeoTIFF options. Compression type:'),
                               self.COMPRESSTYPE, 4))
        params.append(
            ParameterNumber(self.JPEGCOMPRESSION,
                            self.tr('Set the JPEG compression level'), 1, 100,
                            75))
        params.append(
            ParameterNumber(self.ZLEVEL,
                            self.tr('Set the DEFLATE compression level'), 1, 9,
                            6))
        params.append(
            ParameterNumber(
                self.PREDICTOR,
                self.tr('Set the predictor for LZW or DEFLATE compression'), 1,
                3, 1))
        params.append(
            ParameterBoolean(
                self.TILED,
                self.tr(
                    'Create tiled output (only used for the GTiff format)'),
                False))
        params.append(
            ParameterSelection(
                self.BIGTIFF,
                self.
                tr('Control whether the created file is a BigTIFF or a classic TIFF'
                   ), self.BIGTIFFTYPE, 0))
        params.append(
            ParameterBoolean(
                self.TFW,
                self.
                tr('Force the generation of an associated ESRI world file (.tfw))'
                   ), False))
        params.append(
            ParameterString(self.EXTRA,
                            self.tr('Additional creation parameters'),
                            '',
                            optional=True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Reprojected')))
Exemplo n.º 42
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm('gdal2tiles')
        self.group, self.i18n_group = self.trAlgorithm('Raster miscellaneous')

        # Required parameters
        self.addParameter(ParameterRaster(self.INPUT, self.tr('Input layer')))

        # Advanced parameters
        params = []
        params.append(
            ParameterSelection(self.PROFILE,
                               self.tr('Tile cutting profile'),
                               self.PROFILES,
                               0,
                               False,
                               optional=True))
        params.append(
            ParameterSelection(self.RESAMPLING,
                               self.tr('Resampling method'),
                               self.RESAMPLINGS,
                               0,
                               False,
                               optional=True))
        params.append(
            ParameterCrs(
                self.S_SRS,
                self.
                tr('The spatial reference system used for the source input data'
                   ), None, True))
        params.append(
            ParameterString(self.ZOOM, self.tr('Zoom levels to render'), None,
                            False, True))
        params.append(
            ParameterBoolean(
                self.RESUME,
                self.tr('Resume mode, generate only missing files'), False,
                True))
        params.append(
            ParameterString(
                self.NODATA,
                self.tr(
                    'NODATA transparency value to assign to the input data'),
                None, False, True))
        params.append(
            ParameterBoolean(
                self.FORCEKML,
                self.
                tr('Generate KML for Google Earth - default for "geodetic" profile and "raster" in EPSG:4326'
                   ), False, True))
        params.append(
            ParameterBoolean(
                self.NOKML,
                self.tr(
                    'Avoid automatic generation of KML files for EPSG:4326'),
                False, True))
        params.append(
            ParameterString(
                self.URL,
                self.
                tr('URL address where the generated tiles are going to be published'
                   ), None, False, True))
        params.append(
            ParameterSelection(self.WEBVIEWER,
                               self.tr('Web viewer to generate'),
                               self.WEBVIEWERS,
                               0,
                               False,
                               optional=True))
        params.append(
            ParameterString(self.TITLE, self.tr('Title of the map'), None,
                            False, True))
        params.append(
            ParameterString(self.COPYRIGHT, self.tr('Copyright for the map'),
                            None, False, True))
        params.append(
            ParameterString(
                self.GOOGLEKEY,
                self.
                tr('Google Maps API key from http://code.google.com/apis/maps/signup.html'
                   ), None, False, True))
        params.append(
            ParameterString(
                self.BINGKEY,
                self.tr(
                    'Bing Maps API key from https://www.bingmapsportal.com/'),
                None, False, True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(
            OutputDirectory(
                self.OUTPUTDIR,
                self.tr('The directory where the tile result is created')))
Exemplo n.º 43
0
 def addParametersHorizontalFeetGUI(self):
     self.addParameter(
         ParameterBoolean(LAStoolsAlgorithm.HORIZONTAL_FEET,
                          self.tr("horizontal feet"), False))
Exemplo n.º 44
0
    def defineCharacteristics(self):
        self.name, self.i18n_name = self.trAlgorithm(
            'Clip raster by mask layer')
        self.group, self.i18n_group = self.trAlgorithm('[GDAL] Extraction')
        self.addParameter(
            ParameterRaster(self.INPUT, self.tr('Input layer'), False))
        self.addParameter(
            ParameterVector(self.MASK, self.tr('Mask layer'),
                            [dataobjects.TYPE_VECTOR_POLYGON]))
        self.addParameter(
            ParameterString(
                self.NO_DATA,
                self.
                tr("Nodata value, leave blank to take the nodata value from input"
                   ),
                '',
                optional=True))
        self.addParameter(
            ParameterBoolean(self.ALPHA_BAND,
                             self.tr('Create and output alpha band'), False))
        self.addParameter(
            ParameterBoolean(
                self.CROP_TO_CUTLINE,
                self.
                tr('Crop the extent of the target dataset to the extent of the cutline'
                   ), True))
        self.addParameter(
            ParameterBoolean(self.KEEP_RESOLUTION,
                             self.tr('Keep resolution of output raster'),
                             False))

        params = []
        params.append(
            ParameterSelection(self.RTYPE, self.tr('Output raster type'),
                               self.TYPE, 5))
        params.append(
            ParameterSelection(self.COMPRESS,
                               self.tr('GeoTIFF options. Compression type:'),
                               self.COMPRESSTYPE, 4))
        params.append(
            ParameterNumber(self.JPEGCOMPRESSION,
                            self.tr('Set the JPEG compression level'), 1, 100,
                            75))
        params.append(
            ParameterNumber(self.ZLEVEL,
                            self.tr('Set the DEFLATE compression level'), 1, 9,
                            6))
        params.append(
            ParameterNumber(
                self.PREDICTOR,
                self.tr('Set the predictor for LZW or DEFLATE compression'), 1,
                3, 1))
        params.append(
            ParameterBoolean(
                self.TILED,
                self.tr(
                    'Create tiled output (only used for the GTiff format)'),
                False))
        params.append(
            ParameterSelection(
                self.BIGTIFF,
                self.
                tr('Control whether the created file is a BigTIFF or a classic TIFF'
                   ), self.BIGTIFFTYPE, 0))
        params.append(
            ParameterBoolean(
                self.TFW,
                self.
                tr('Force the generation of an associated ESRI world file (.tfw))'
                   ), False))
        params.append(
            ParameterString(self.EXTRA,
                            self.tr('Additional creation parameters'),
                            '',
                            optional=True))

        for param in params:
            param.isAdvanced = True
            self.addParameter(param)

        self.addOutput(OutputRaster(self.OUTPUT, self.tr('Clipped (mask)')))