Ejemplo n.º 1
0
    def defineCharacteristics(self):
        self.name = 'D-Infinity Transport Limited Accumulation - 2'
        self.cmdName = 'dinftranslimaccum'
        self.group = 'Specialized Grid Analysis tools'

        self.addParameter(
            ParameterRaster(self.DINF_FLOW_DIR_GRID,
                            'D-Infinity Flow Direction Grid', False))
        self.addParameter(
            ParameterRaster(self.SUPPLY_GRID, 'Supply Grid', False))
        self.addParameter(
            ParameterRaster(self.CAPACITY_GRID, 'Transport Capacity Grid',
                            False))
        self.addParameter(
            ParameterRaster(self.IN_CONCENTR_GRID, 'Input Concentration Grid',
                            False))
        self.addParameter(
            ParameterVector(self.OUTLETS_SHAPE, 'Outlets Shapefile',
                            [ParameterVector.VECTOR_TYPE_POINT], True))
        self.addParameter(
            ParameterBoolean(self.EDGE_CONTAM, 'Check for edge contamination',
                             True))

        self.addOutput(
            OutputRaster(self.TRANSP_LIM_ACCUM_GRID,
                         'Transport Limited Accumulation Grid'))
        self.addOutput(OutputRaster(self.DEPOSITION_GRID, 'Deposition Grid'))
        self.addOutput(
            OutputRaster(self.OUT_CONCENTR_GRID, 'Output Concentration Grid'))
Ejemplo n.º 2
0
 def defineCharacteristics(self):
     self.name = "Split RGB bands"
     self.group = "Grid - Tools"
     self.addParameter(
         ParameterRaster(SplitRGBBands.INPUT, "Input layer", False))
     self.addOutput(OutputRaster(SplitRGBBands.R, "Output R band layer"))
     self.addOutput(OutputRaster(SplitRGBBands.G, "Output G band layer"))
     self.addOutput(OutputRaster(SplitRGBBands.B, "Output B band layer"))
Ejemplo n.º 3
0
 def defineCharacteristics(self):
     self.name = 'Split RGB bands'
     self.group = 'Grid - Tools'
     self.addParameter(ParameterRaster(SplitRGBBands.INPUT, 'Input layer',
                       False))
     self.addOutput(OutputRaster(SplitRGBBands.R, 'Output R band layer'))
     self.addOutput(OutputRaster(SplitRGBBands.G, 'Output G band layer'))
     self.addOutput(OutputRaster(SplitRGBBands.B, 'Output B band layer'))
Ejemplo n.º 4
0
    def defineCharacteristics(self):
        self.name = 'Grid (Data metrics)'
        self.group = '[GDAL] Analysis'
        self.addParameter(
            ParameterVector(self.INPUT, 'Input layer',
                            [ParameterVector.VECTOR_TYPE_POINT]))
        self.addParameter(
            ParameterTableField(self.Z_FIELD, 'Z field', self.INPUT,
                                ParameterTableField.DATA_TYPE_NUMBER, True))
        self.addParameter(
            ParameterSelection(self.METRIC, 'Metrics', self.DATA_METRICS, 0))
        self.addParameter(
            ParameterNumber(self.RADIUS_1, 'Radius 1', 0.0, 99999999.999999,
                            0.0))
        self.addParameter(
            ParameterNumber(self.RADIUS_2, 'Radius 2', 0.0, 99999999.999999,
                            0.0))
        self.addParameter(
            ParameterNumber(self.MIN_POINTS, 'Min points', 0.0,
                            99999999.999999, 0.0))
        self.addParameter(ParameterNumber(self.ANGLE, 'Angle', 0.0, 359.0,
                                          0.0))
        self.addParameter(
            ParameterNumber(self.NODATA, 'Nodata', 0.0, 99999999.999999, 0.0))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output file'))
Ejemplo n.º 5
0
    def defineCharacteristics(self):
        self.name = 'Hillshade'
        self.group = '[GDAL] Analysis'
        self.addParameter(ParameterRaster(self.INPUT, 'Input layer'))
        self.addParameter(ParameterNumber(self.BAND, 'Band number', 1, 99, 1))
        self.addParameter(
            ParameterBoolean(self.COMPUTE_EDGES, 'Compute edges', False))
        self.addParameter(
            ParameterBoolean(
                self.ZEVENBERGEN,
                "Use Zevenbergen&Thorne formula (instead of the Horn's one)",
                False))
        self.addParameter(
            ParameterNumber(self.Z_FACTOR, 'Z factor (vertical exaggeration)',
                            0.0, 99999999.999999, 1.0))
        self.addParameter(
            ParameterNumber(self.SCALE,
                            'Scale (ratio of vert. units to horiz.)', 0.0,
                            99999999.999999, 1.0))
        self.addParameter(
            ParameterNumber(self.AZIMUTH, 'Azimuth of the light', 0.0, 359.0,
                            315.0))
        self.addParameter(
            ParameterNumber(self.ALTITUDE, 'Altitude of the light', 0.0,
                            99999999.999999, 45.0))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output file'))
Ejemplo n.º 6
0
 def defineCharacteristics(self):
     self.name = "Merge"
     self.group = "[GDAL] Miscellaneous"
     self.addParameter(ParameterMultipleInput(merge.INPUT, "Input layers", ParameterMultipleInput.TYPE_RASTER))
     self.addParameter(ParameterBoolean(merge.PCT, "Grab pseudocolor table from first layer", False))
     self.addParameter(ParameterBoolean(merge.SEPARATE, "Layer stack", False))
     self.addOutput(OutputRaster(merge.OUTPUT, "Output layer"))
Ejemplo n.º 7
0
    def defineCharacteristics(self):
        self.name = 'D-Infinity Distance Down'
        self.cmdName = 'dinfdistdown'
        self.group = 'Specialized Grid Analysis tools'

        self.addParameter(
            ParameterRaster(self.DINF_FLOW_DIR_GRID,
                            'D-Infinity Flow Direction Grid', False))
        self.addParameter(
            ParameterRaster(self.PIT_FILLED_GRID, 'Pit Filled Elevation Grid',
                            False))
        self.addParameter(
            ParameterRaster(self.STREAM_GRID, 'Stream Raster Grid', False))
        self.addParameter(
            ParameterRaster(self.WEIGHT_PATH_GRID, 'Weight Path Grid', True))
        self.addParameter(
            ParameterSelection(self.STAT_METHOD, 'Statistical Method',
                               self.STATISTICS, 2))
        self.addParameter(
            ParameterSelection(self.DIST_METHOD, 'Distance Method',
                               self.DISTANCE, 1))
        self.addParameter(
            ParameterBoolean(self.EDGE_CONTAM, 'Check for edge contamination',
                             True))

        self.addOutput(
            OutputRaster(self.DIST_DOWN_GRID,
                         'D-Infinity Drop to Stream Grid'))
Ejemplo n.º 8
0
 def defineCharacteristics(self):
     self.name = "rgb2pct"
     self.group = "[GDAL] Conversion"
     self.addParameter(ParameterRaster(rgb2pct.INPUT, "Input layer", False))
     self.addParameter(
         ParameterNumber(rgb2pct.NCOLORS, "Number of colors", 1, None, 2))
     self.addOutput(OutputRaster(rgb2pct.OUTPUT, "Output layer"))
Ejemplo n.º 9
0
 def defineCharacteristics(self):
     self.name = 'From Datum 73 to ETRS89-PTTM06 Raster'
     self.group = 'Raster Datum Transformations'
     self.addParameter(ParameterRaster(self.INPUT, 'Input layer', False))
     self.addParameter(ParameterSelection(self.GRID, 'NTv2 Grid to use (source)',
                       self.GRID_OPTIONS))
     self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Ejemplo n.º 10
0
    def defineCharacteristics(self):
        self.name = 'Grid (Inverse distance to a power)'
        self.group = '[GDAL] Analysis'
        self.addParameter(
            ParameterVector(self.INPUT, 'Input layer',
                            [ParameterVector.VECTOR_TYPE_POINT]))
        self.addParameter(
            ParameterTableField(self.Z_FIELD, 'Z field', self.INPUT,
                                ParameterTableField.DATA_TYPE_NUMBER, True))
        self.addParameter(ParameterNumber(self.POWER, 'Power', 0, 100.0, 2.0))
        self.addParameter(
            ParameterNumber(self.SMOTHING, 'Smothing', 0.0, 99999999.999999,
                            0.0))
        self.addParameter(
            ParameterNumber(self.RADIUS_1, 'Radius 1', 0.0, 99999999.999999,
                            0.0))
        self.addParameter(
            ParameterNumber(self.RADIUS_2, 'Radius 2', 0.0, 99999999.999999,
                            0.0))
        self.addParameter(
            ParameterNumber(self.MAX_POINTS, 'Max points', 0.0,
                            99999999.999999, 0.0))
        self.addParameter(
            ParameterNumber(self.MIN_POINTS, 'Min points', 0.0,
                            99999999.999999, 0.0))
        self.addParameter(ParameterNumber(self.ANGLE, 'Angle', 0.0, 359.0,
                                          0.0))
        self.addParameter(
            ParameterNumber(self.NODATA, 'Nodata', -99999999.999999,
                            99999999.999999, 0.0))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output file'))
Ejemplo n.º 11
0
 def defineCharacteristics(self):
     self.name = 'Create constant raster layer'
     self.group = 'Raster tools'
     self.addParameter(ParameterRaster(self.INPUT, 'Reference layer'))
     self.addParameter(
         ParameterNumber(self.NUMBER, 'Constant value', default=1.0))
     self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Ejemplo n.º 12
0
 def defineCharacteristics(self):
     self.name = "Create constant raster layer"
     self.group = "Raster tools"
     self.addParameter(ParameterRaster(self.INPUT, "Reference layer"))
     self.addParameter(
         ParameterNumber(self.NUMBER, "Constant value", default=1.0))
     self.addOutput(OutputRaster(self.OUTPUT, "Output layer"))
Ejemplo n.º 13
0
    def defineCharacteristics(self):
        self.name = 'D-Infinity Distance Up'
        self.cmdName = 'dinfdistup'
        self.group = 'Specialized Grid Analysis tools'

        self.addParameter(
            ParameterRaster(self.DINF_FLOW_DIR_GRID,
                            'D-Infinity Flow Direction Grid', False))
        self.addParameter(
            ParameterRaster(self.PIT_FILLED_GRID, 'Pit Filled Elevation Grid',
                            False))
        self.addParameter(ParameterRaster(self.SLOPE_GRID, 'Slope Grid',
                                          False))
        self.addParameter(
            ParameterSelection(self.STAT_METHOD, 'Statistical Method',
                               self.STATISTICS, 2))
        self.addParameter(
            ParameterSelection(self.DIST_METHOD, 'Distance Method',
                               self.DISTANCE, 1))
        self.addParameter(
            ParameterNumber(self.THRESHOLD, 'Proportion Threshold', 0, None,
                            0.5))
        self.addParameter(
            ParameterBoolean(self.EDGE_CONTAM, 'Check for edge contamination',
                             True))

        self.addOutput(
            OutputRaster(self.DIST_UP_GRID, 'D-Infinity Distance Up'))
Ejemplo n.º 14
0
 def defineCharacteristics(self):
     self.name = 'RGB to PCT'
     self.group = '[GDAL] Conversion'
     self.addParameter(ParameterRaster(rgb2pct.INPUT, 'Input layer', False))
     self.addParameter(
         ParameterNumber(rgb2pct.NCOLORS, 'Number of colors', 1, None, 2))
     self.addOutput(OutputRaster(rgb2pct.OUTPUT, 'Output layer'))
Ejemplo n.º 15
0
 def defineCharacteristics(self):
     self.name = "Nearblack"
     self.group = "[GDAL] Analysis"
     self.addParameter(ParameterRaster(nearblack.INPUT, "Input layer", False))
     self.addParameter(ParameterNumber(nearblack.NEAR, "How far from black (white)", 0, None, 15))
     self.addParameter(ParameterBoolean(nearblack.WHITE, "Search for nearly white pixels instead of nearly black", False))
     self.addOutput(OutputRaster(nearblack.OUTPUT, "Output layer"))
Ejemplo n.º 16
0
 def defineCharacteristics(self):
     self.name = "Mean based on band indexes"
     self.group = "[permaclim]"
     self.addParameter(ParameterRaster(BandMean.INPUT, "Weekly mean layer"))
     self.addParameter(ParameterNumber(BandMean.FIRST_BAND, "First Band", default=1))
     self.addParameter(ParameterNumber(BandMean.LAST_BAND, "Last Band", default=2))
     self.addOutput(OutputRaster(BandMean.OUTPUT, "Layer with the mean of the choosed bands"))
Ejemplo n.º 17
0
 def defineCharacteristics(self):
     self.name = 'Translate (convert format)'
     self.group = '[GDAL] Conversion'
     self.addParameter(ParameterRaster(self.INPUT, 'Input layer',
                       False))
     self.addParameter(ParameterNumber(self.OUTSIZE,
                       'Set the size of the output file (In pixels or %)',
                       1, None, 100))
     self.addParameter(ParameterBoolean(self.OUTSIZE_PERC,
                       'Output size is a percentage of input size', True))
     self.addParameter(ParameterString(self.NO_DATA,
         'Nodata value, leave as none to take the nodata value from input',
         'none'))
     self.addParameter(ParameterSelection(self.EXPAND, 'Expand',
                       ['none', 'gray', 'rgb', 'rgba']))
     self.addParameter(ParameterCrs(self.SRS,
                       'Override the projection for the output file', None))
     self.addParameter(ParameterExtent(self.PROJWIN,
                       'Subset based on georeferenced coordinates'))
     self.addParameter(ParameterBoolean(self.SDS,
         'Copy all subdatasets of this file to individual output files',
         False))
     self.addParameter(ParameterString(self.EXTRA,
                       'Additional creation parameters', ''))
     self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Ejemplo n.º 18
0
 def defineCharacteristics(self):
     self.name = "Build pyramids (overviews)"
     self.group = "[GDAL] Miscellaneous"
     self.addParameter(ParameterRaster(gdaladdo.INPUT, "Input layer",
                                       False))
     self.addParameter(
         ParameterString(gdaladdo.LEVELS, "Overview levels", "2 4 8 16"))
     self.addOutput(OutputRaster(gdaladdo.OUTPUT, "Output layer", True))
Ejemplo n.º 19
0
 def defineCharacteristics(self):
     self.allowOnlyOpenedLayers = True
     self.name = 'Set style for raster layer'
     self.group = 'Raster general tools'
     self.addParameter(ParameterRaster(self.INPUT, 'Vector layer'))
     self.addParameter(
         ParameterFile(self.STYLE, 'Style file', False, False, 'qml'))
     self.addOutput(OutputRaster(self.OUTPUT, 'Styled layer', True))
Ejemplo n.º 20
0
    def buildParametersDialog(self):
        for input in self.process.inputs:
            inputType = type(input)
            if inputType == VectorInput:
                self.addParameter(
                    ParameterVector(str(input.identifier), str(input.title),
                                    ParameterVector.VECTOR_TYPE_ANY,
                                    input.minOccurs == 0))
            elif inputType == MultipleVectorInput:
                self.addParameter(
                    ParameterMultipleInput(str(input.identifier),
                                           str(input.title),
                                           ParameterVector.VECTOR_TYPE_ANY,
                                           input.minOccurs == 0))
            elif inputType == StringInput:
                self.addParameter(
                    ParameterString(str(input.identifier), str(input.title)))
            elif inputType == TextInput:
                self.addParameter(
                    ParameterString(str(input.identifier), str(input.title)))
            elif inputType == RasterInput:
                self.addParameter(
                    ParameterRaster(str(input.identifier), str(input.title),
                                    input.minOccurs == 0))
            elif inputType == MultipleRasterInput:
                self.addParameter(
                    ParameterMultipleInput(str(input.identifier),
                                           str(input.title),
                                           ParameterMultipleInput.TYPE_RASTER,
                                           input.minOccurs == 0))
            elif inputType == FileInput:
                #self.addParameter(ParameterFile(str(input.identifier), str(input.title), False, input.minOccurs == 0))
                self.addParameter(
                    ParameterFile(str(input.identifier), str(input.title)))
            elif inputType == MultipleFileInput:
                pass  #Not supported
            elif inputType == SelectionInput:
                self.addParameter(
                    ParameterSelection(str(input.identifier), str(input.title),
                                       input.valList))
            elif inputType == ExtentInput:
                self.addParameter(
                    ParameterExtent(str(input.identifier), str(input.title)))
            elif inputType == CrsInput:
                self.addParameter(
                    ParameterCrs(str(input.identifier), "Projection", None))

        for output in self.process.outputs:
            outputType = type(output)
            if outputType == VectorOutput:
                self.addOutput(
                    OutputVector(str(output.identifier), str(output.title)))
            elif outputType == RasterOutput:
                self.addOutput(
                    OutputRaster(str(output.identifier), str(output.title)))
            elif outputType == StringOutput:
                self.addOutput(
                    OutputString(str(output.identifier), str(output.title)))
Ejemplo n.º 21
0
    def defineCharacteristics(self):
        self.name = 'TPI (Topographic Position Index)'
        self.group = '[GDAL] Analysis'
        self.addParameter(ParameterRaster(self.INPUT, 'Input layer'))
        self.addParameter(ParameterNumber(self.BAND, 'Band number', 1, 99, 1))
        self.addParameter(ParameterBoolean(self.COMPUTE_EDGES, 'Compute edges',
                          False))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output file'))
 def defineCharacteristics(self):
     self.name = 'De Datum Lisboa para PT-TM06/ETRS89 Raster'
     self.group = 'Transformação de Datum em Rasters'
     self.addParameter(
         ParameterRaster(self.INPUT, 'Ficheiro de Entrada', False))
     self.addParameter(
         ParameterSelection(self.GRID, 'Grelha NTv2 a usar (Fonte)',
                            self.GRID_OPTIONS))
     self.addOutput(OutputRaster(self.OUTPUT, 'Ficheiro de Saída'))
Ejemplo n.º 23
0
 def defineCharacteristics(self):
     self.name = "las2dem"
     self.group = "Tools"
     self.addParameter(ParameterFile(las2dem.INPUT, "Input las layer"))
     self.addParameter(
         ParameterBoolean(las2dem.INTENSITY,
                          "Use intensity instead of elevation", False))
     self.addOutput(OutputRaster(las2dem.OUTPUT, "Output dem layer"))
     self.addCommonParameters()
Ejemplo n.º 24
0
 def defineCharacteristics(self):
     self.name = "Distribution of snow based on slope"
     self.group = "[permaclim]"
     self.addParameter(
         ParameterRaster(SnowDistributionBySlope.SLOPE, "Slope"))
     self.addParameter(
         ParameterRaster(SnowDistributionBySlope.HN, "Snow heigth"))
     self.addOutput(
         OutputRaster(SnowDistributionBySlope.OUTPUT,
                      "Snow height based on slope"))
Ejemplo n.º 25
0
 def defineCharacteristics(self):
     self.name = 'PCT to RGB'
     self.group = '[GDAL] Conversion'
     self.addParameter(ParameterRaster(pct2rgb.INPUT, 'Input layer', False))
     options = []
     for i in range(25):
         options.append(str(i + 1))
     self.addParameter(
         ParameterSelection(pct2rgb.NBAND, 'Band to convert', options))
     self.addOutput(OutputRaster(pct2rgb.OUTPUT, 'Output layer'))
Ejemplo n.º 26
0
 def defineCharacteristics(self):
     self.name = 'Data transformation (Simple)'
     self.cmdName = 'transformationSimple'
     self.group = 'Data Preperation'
     
     self.addParameter(ParameterRaster(self.RASTER, "Input Grid", False))
     self.addParameter(ParameterSelection(self.TRANSFORM, "Transformation method", self.tsel, 0))
     self.addParameter(ParameterNumber(self.POLYNOM, "Polynominal Expansion on n=", 2, None, 1))
     
     self.addOutput(OutputRaster(self.OUT,'Transformed Raster'))
Ejemplo n.º 27
0
 def defineCharacteristics(self):
     self.name = "pct2rgb"
     self.group = "[GDAL] Conversion"
     self.addParameter(ParameterRaster(pct2rgb.INPUT, "Input layer", False))
     options = []
     for i in range(25):
         options.append(str(i + 1))
     self.addParameter(
         ParameterSelection(pct2rgb.NBAND, "Band to convert", options))
     self.addOutput(OutputRaster(pct2rgb.OUTPUT, "Output layer"))
Ejemplo n.º 28
0
    def defineCharacteristics(self):
        self.name = 'Sieve'
        self.group = '[GDAL] Analysis'
        self.addParameter(ParameterRaster(self.INPUT, 'Input layer', False))
        self.addParameter(ParameterNumber(self.THRESHOLD, 'Threshold', 0,
                          9999, 2))
        self.addParameter(ParameterSelection(self.CONNECTIONS,
                          'Pixel connection', self.PIXEL_CONNECTIONS, 0))

        self.addOutput(OutputRaster(self.OUTPUT, 'Output layer'))
Ejemplo n.º 29
0
 def defineCharacteristics(self):
     self.name = '[CH] Direct and inverse Raster transformation'
     self.group = '[CH] Switzerland'
     self.addParameter(ParameterRaster(self.INPUT, 'Input raster', False))
     self.addParameter(ParameterSelection(self.TRANSF, 'Transformation',
                       self.TRANSF_OPTIONS))
     self.addParameter(ParameterSelection(self.CRS, 'New Datum',
                       self.CRS_OPTIONS))
     self.addParameter(ParameterSelection(self.GRID, 'NTv2 Grid',
                       self.GRID_OPTIONS))
     self.addOutput(OutputRaster(self.OUTPUT, 'Output'))
Ejemplo n.º 30
0
    def defineCharacteristics(self):
        '''Here we define the inputs and output of the algorithm, along
        with some other properties'''

        self.name = "Linear rescale"
        self.cmdName = "nlmpy:linearrescale"
        self.group = "Neutral landscape model (NLMpy)"

        self.addParameter(ParameterRaster(self.SOURCE, "Source raster layer", True))
        self.addOutput(OutputRaster(self.OUTPUT_RASTER, "Result output"))
        self.addParameter(ParameterNumber(self.CS, "Output Cellsize", 10, None, 1))
Ejemplo n.º 31
0
    def processParameterLine(self,line):
        param = None
        out = None
        line = line.replace("#", "");
        # If the line is in the format of the text description files for normal algorithms,
        # then process it using parameter and output factories
        if '|' in line:
            self.processDescriptionParameterLine(line)
            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() == "name":
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == "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() == "table":
            param = ParameterTable(tokens[0], desc, False)
        elif tokens[1].lower().strip() == "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() == "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("number"):
            default = tokens[1].strip()[len("number")+1:]
            param = ParameterNumber(tokens[0],  desc, default=default)
        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().startswith("string"):
            default = tokens[1].strip()[len("string")+1:]
            param = ParameterString(tokens[0],  desc, default)
        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 html"):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()
        elif tokens[1].lower().strip().startswith("output number"):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith("output string"):
            out = OutputString()

        if param != None:
            self.addParameter(param)
        elif out != None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException("Could not load script:" + self.descriptionFile + ".\n Problem with line \"" + line + "\"")
Ejemplo n.º 32
0
    def processParameterLine(self, line):
        param = None
        out = None
        line = line.replace('#', '')

        # If the line is in the format of the text description files for
        # normal algorithms, then process it using parameter and output
        # factories
        if '|' in line:
            self.processDescriptionParameterLine(line)
            return
        tokens = line.split('=', 1)
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == 'group':
            self.group = tokens[0]
            return
        if tokens[1].lower().strip() == 'name':
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == '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() == '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() == '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('number'):
            default = tokens[1].strip()[len('number') + 1:]
            param = ParameterNumber(tokens[0], desc, default=default)
        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().startswith('string'):
            default = tokens[1].strip()[len('string') + 1:]
            param = ParameterString(tokens[0], desc, default)
        elif tokens[1].lower().strip().startswith('crs'):
            default = tokens[1].strip()[len('crs') + 1:]
            if not default:
                default = 'EPSG:4326'
            param = ParameterCrs(tokens[0], desc, default)
        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 html'):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith('output file'):
            out = OutputFile()
        elif tokens[1].lower().strip().startswith('output number'):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith('output string'):
            out = OutputString()

        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('Could not load script:'
                                       + self.descriptionFile
                                       + '.\n Problem with line "' + line + '"'
                                       )
Ejemplo n.º 33
0
    def processParameterLine(self, line):
        param = None
        out = None
        line = line.replace("#", "")

        # If the line is in the format of the text description files for
        # normal algorithms, then process it using parameter and output
        # factories
        if "|" in line:
            self.processDescriptionParameterLine(line)
            return
        if line == "nomodeler":
            self.showInModeler = False
            return
        tokens = line.split("=", 1)
        desc = self.createDescriptiveName(tokens[0])
        if tokens[1].lower().strip() == "group":
            self.group = tokens[0]
            return
        if tokens[1].lower().strip() == "name":
            self.name = tokens[0]
            return
        if tokens[1].lower().strip() == "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() == "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() == "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("number"):
            default = tokens[1].strip()[len("number") + 1 :]
            param = ParameterNumber(tokens[0], desc, default=default)
        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], desc, field)
        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("crs"):
            default = tokens[1].strip()[len("crs") + 1 :]
            if not default:
                default = "EPSG:4326"
            param = ParameterCrs(tokens[0], desc, default)
        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 html"):
            out = OutputHTML()
        elif tokens[1].lower().strip().startswith("output file"):
            out = OutputFile()
            subtokens = tokens[1].split(" ")
            if len(subtokens > 2):
                out.ext = subtokens[2]
        elif tokens[1].lower().strip().startswith("output directory"):
            out = OutputDirectory()
        elif tokens[1].lower().strip().startswith("output number"):
            out = OutputNumber()
        elif tokens[1].lower().strip().startswith("output string"):
            out = OutputString()

        if param is not None:
            self.addParameter(param)
        elif out is not None:
            out.name = tokens[0]
            out.description = desc
            self.addOutput(out)
        else:
            raise WrongScriptException(
                "Could not load script:" + self.descriptionFile or "" + '.\n Problem with line "' + line + '"'
            )
Ejemplo n.º 34
0
    def processAlgorithm(self, progress):
        currentPath = os.path.dirname(os.path.abspath(__file__))
        outputs = os.path.join(currentPath, 'outputs')
        if not os.path.exists(outputs):
            os.mkdir(outputs)

        # Get parameters
        perc = self.getParameterValue(kernelDensity.PERCENT)
        field = self.getParameterValue(kernelDensity.FIELD)
        inputLayer = getObjectFromUri(
                            self.getParameterValue(kernelDensity.INPUT))
        resolution = self.getParameterValue(kernelDensity.RESOLUTION)
        bw_method = kernelDensity.BW_METHODS.keys()[
                        self.getParameterValue(kernelDensity.BW_METHOD)]
        addRasterOutputs = self.getParameterValue(
                            kernelDensity.ADD_RASTER_OUTPUTS)

        # Adjust parameters if necessary
        if perc > 100:
            perc = 100
        if bw_method == kernelDensity.BW_METHOD_DEFAULT:
            bandwidth = 'normal_reference'
        elif bw_method == kernelDensity.BW_METHOD_SCOTT:
            bandwidth = 'scott'
        elif bw_method == kernelDensity.BW_METHOD_SILVERMAN:
            bandwidth = 'silverman'
        elif bw_method == kernelDensity.BW_METHOD_CV_ML:
            bandwidth = 'cv_ml'
        elif bw_method == kernelDensity.BW_METHOD_CV_LS:
            bandwidth = 'cv_ls'
        elif bw_method == kernelDensity.BW_METHOD_CUSTOM:
            if _HAS_SCIPY and 'set_bandwidth' in dir(gaussian_kde):
                bandwidth = self.getParameterValue(kernelDensity.BW_VALUE)
            else:
                bandwidth = [self.getParameterValue(kernelDensity.BW_VALUE)]

        # Get layer info and create the writer for the output layer
        epsg = inputLayer.crs().srsid()
        name = inputLayer.name()
        inputProvider = inputLayer.dataProvider()
        try:
            inputProvider.select(inputProvider.attributeIndexes())
        except:
            pass

        fieldIndex = inputProvider.fieldNameIndex(field)

        try:
            uniqueValues = getUniqueValues(inputProvider, fieldIndex)
        except:
            uniqueValues = getUniqueValues(inputLayer, fieldIndex)

        fields = [QgsField("ID", QVariant.String),
                  QgsField("Area", QVariant.Double),
                  QgsField("Perim", QVariant.Double)]
        writer = self.getWriter(kernelDensity.OUTPUT, fields,
                    QGis.WKBMultiLineString, inputProvider.crs())

        # Prepare percentage progress and start
        progress_perc = 100 / len(uniqueValues)
        n = 0
        for value in uniqueValues:
            # Filter x,y points with desired field value (value)
            xPoints = []
            yPoints = []
            for feature in features(inputLayer):
                fieldValue = self.getFeatureAttributes(feature)[fieldIndex]
                if (fieldValue == value):
                    points = extractPoints(feature.geometry())
                    xPoints.append(points[0].x())
                    yPoints.append(points[0].y())

            if len(xPoints) == 0:  # number of selected features
                continue

            # Compute kernel (X, Y, Z)
            xmin = min(xPoints) - 0.5 * (max(xPoints) - min(xPoints))
            xmax = max(xPoints) + 0.5 * (max(xPoints) - min(xPoints))
            ymin = min(yPoints) - 0.5 * (max(yPoints) - min(yPoints))
            ymax = max(yPoints) + 0.5 * (max(yPoints) - min(yPoints))

            # X, Y form a meshgrid
            X, Y = np.mgrid[xmin:xmax:complex(resolution),
                            ymin:ymax:complex(resolution)]

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO, "X shape : "
               + str(X.shape))

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO, "Y shape : "
               + str(Y.shape))

            # Meshgrid in form of stacked array with all possible positions
            positions = np.vstack([X.ravel(), Y.ravel()])

            # Meshgrid with all the real positions
            values = np.vstack([xPoints, yPoints])

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO, "Positions shape : "
               + str(positions.shape))

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO, "Values shape : "
               + str(values.shape))

            if self.use_scipy(bw_method):
                ###############################################################
                # Compute kernel Z with scipy.stats.kde.gaussian_kde
                # Representation of a kernel-density estimate using Gaussian
                # kernels.
                # Taken from http://docs.scipy.org/doc/scipy/reference/
                #            generated/scipy.stats.gaussian_kde.html
                # You need at least version 0.11 of scipy
                ###############################################################
                kernel = gaussian_kde(values)
                try:
                    kernel.set_bandwidth(bandwidth)
                except:
                    if bandwidth == 'scott':
                        kernel.covariance_factor = kernel.scotts_factor
                    elif bandwidth == 'silverman':
                        kernel.covariance_factor = kernel.silverman_factor
                Z = np.reshape(kernel(positions).T, X.T.shape)
                ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                    "Bandwidth value for '"
                    + str(value) + "': "
                    + str(kernel.covariance_factor()))
            else:
                ##############################################################
                # Compute kernel Z with
                #    statsmodels.nonparametric.kernel_density.KDEMultivariate
                # Representation of a kernel-density estimate
                # Taken from http://goo.gl/kwEfD
                # You need at least version 0.5 of statsmodels
                ##############################################################
                kernel = kernel_density.KDEMultivariate(data=values,
                                var_type='cc', bw=bandwidth)
                # Evaluate positions using kernel
                Z = np.reshape(kernel.pdf(positions).T, X.T.shape)
                ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                    "Bandwidth value for: "
                    + str(value) + "': " + str(kernel.bw))

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                "Shape of evaluation transponse : " + str(Z.T.shape))

            # Write kernel to GeoTIFF
            raster_name = (str(name) + '_' + str(perc) + '_' +
                        str(value) + '_' +
                        str(datetime.date.today()))

            fileName = os.path.join(outputs, raster_name)

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO, "Writing '"
               + fileName + "' to disc")

            self.to_geotiff(fileName, xmin, xmax, ymin, ymax, X, Y, Z, epsg)

            if addRasterOutputs:
                ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                        "Adding raster output as layer")
                rasterOutput = OutputRaster(fileName, "Raster output")
                self.addOutput(rasterOutput)
                rasterOutput.setValue(fileName)

            # Create contour lines (temporary .shp) from GeoTIFF
            basename = "animove_tmp_" + str(n)
            shpFile = os.path.join(outputs, basename + ".shp")

            args = ['gdal_contour', fileName, '-a', 'values',
                    '-i', '10', shpFile]
            ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                    "Creating contour lines for GeoTIFF: " + str(args))

            startupinfo = None
            try:
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            except:
                pass
            process = subprocess.Popen(args, startupinfo=startupinfo)
            process.wait()

            # Read contour lines from temporary .shp
            ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                    "Reading contour lines from temporary SHP: " + shpFile)

            layer = QgsVectorLayer(shpFile, basename, "ogr")
            provider = layer.dataProvider()
            try:
                provider.select(provider.attributeIndexes())
            except:
                pass

            # Create an array containing all polylines in the temporary
            # .shp and compute the sum of all areas and perimeters
            ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                                   "Creating polylines from all SHP")
            outGeom = []
            area = 0
            perim = 0
            measure = QgsDistanceArea()
            for feat in features(layer):
                polyline = feat.geometry().asPolyline()
                polygon = QgsGeometry.fromPolygon([polyline])
                perim += measure.measurePerimeter(polygon)
                area += measure.measure(polygon)
                outGeom.append(polyline)

            # Create feature and write
            ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                                 "Writing polylines features")
            outFeat = QgsFeature()
            outFeat.setGeometry(QgsGeometry.fromMultiPolyline(outGeom))
            self.setFeatureAttributes(outFeat, [value, area, perim])
            writer.addFeature(outFeat)

            ProcessingLog.addToLog(ProcessingLog.LOG_INFO,
                                   "Updating progress bar")

            n += 1
            progress.setPercentage(progress_perc * n)

        ProcessingLog.addToLog(ProcessingLog.LOG_INFO, "Finished. Removing "
                             "temporary files and deleting writer")
        del writer

        for f in os.listdir(outputs):
            if re.search("animove_tmp_*", f):
                try:
                    os.remove(os.path.join(outputs, f))
                except OSError:
                    ProcessingLog.addToLog(ProcessingLog.LOG_WARNING,
                            "Cannot remove " + f)
Ejemplo n.º 35
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() == "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("Could not load R script:" + self.descriptionFile + ".\n Problem with line \"" + 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("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 != None:
            self.addParameter(param)
        elif out != None:
            out.name = tokens[0]
            out.description = tokens[0]
            self.addOutput(out)
        else:
            raise WrongScriptException("Could not load R script:" + self.descriptionFile + ".\n Problem with line \"" + line + "\"")
Ejemplo n.º 36
0
 def processParameterLine(self, line):
     param = None
     out = None
     line = line.replace('#', '')
     if line.lower().strip().startswith('report'):
         self.report = True
         self.addOutput(OutputHTML(RAlgorithm.KNITR_REPORT, 'HTML Report'))
         return
     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
     if line.lower().strip().startswith('shapefilespackage'):
         self.useShapefilesPackage = 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() == '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('Could not load R script:'
                     + self.descriptionFile + '.\n Problem with line "'
                     + 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], desc, 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('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()
     elif tokens[1].lower().strip().startswith('output string'):
         out = OutputString()
         self.outputStringExist = True
         self.outputStringName = tokens[0]
     elif tokens[1].lower().strip().startswith('output number'):
         out = OutputNumber()
         self.outputNumberBool = True
         self.outputNumberName = tokens[0]
         
     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('Could not load R script:'
                                    + self.descriptionFile
                                    + '.\n Problem with line "' + line + '"'
                                    )