| pktools 2.6.7 Processing Kernel for geospatial data

pkfilterdem.py
1# -*- coding: utf-8 -*-
2
3"""
4***************************************************************************
5 pkfilterdem.py
6 ---------------------
7 Date : April 2015
8 Copyright : (C) 2015 by Pieter Kempeneers
9 Email : kempenep at gmail dot com
10***************************************************************************
11* *
12* This program is free software; you can redistribute it and/or modify *
13* it under the terms of the GNU General Public License as published by *
14* the Free Software Foundation; either version 2 of the License, or *
15* (at your option) any later version. *
16* *
17***************************************************************************
18"""
19
20__author__ = 'Pieter Kempeneers'
21__date__ = 'April 2015'
22__copyright__ = '(C) 2015, Pieter Kempeneers'
23# This will get replaced with a git SHA1 when you do a git archive
24__revision__ = '$Format:%H$'
25
26 import os
27 from pktoolsUtils import pktoolsUtils
28 from pktoolsAlgorithm import pktoolsAlgorithm
29 from processing.core.parameters import ParameterMultipleInput
30 from processing.core.parameters import ParameterRaster
31 from processing.core.parameters import ParameterFile
32 from processing.core.outputs import OutputRaster
33 from processing.core.parameters import ParameterSelection
34 from processing.core.parameters import ParameterNumber
35 from processing.core.parameters import ParameterString
36 from processing.core.parameters import ParameterBoolean
37 from processing.core.parameters import ParameterExtent
38
39 class pkfilterdem(pktoolsAlgorithm):
40
41 INPUT = "INPUT"
42 OUTPUT = "OUTPUT"
43 DIM = "DIM"
44 RTYPE = 'RTYPE'
45 TYPE = ['Float32','Byte','Int16','UInt16','UInt32','Int32','Float64','CInt16','CInt32','CFloat32','CFloat64']
46 FILTER_OPTIONS = ["promorph"]
47 FILTER = "FILTER"
48 EXTRA = 'EXTRA'
49
50 def cliName(self):
51 return "pkfilterdem"
52
53 def defineCharacteristics(self):
54 self.name = "Create DTM from DEM raster dataset)"
55 self.group = "[pktools] LiDAR"
56
57 self.addParameter(ParameterRaster(self.INPUT, 'Input layer raster data set',ParameterRaster))
58 self.addParameter(ParameterSelection(self.FILTER,"filter",self.FILTER_OPTIONS, 0))
59 self.addParameter(ParameterNumber(self.DIM, "maximum filter kernel size",3,None,17))
60
61 self.addOutput(OutputRaster(self.OUTPUT, "Output raster data set"))
62 self.addParameter(ParameterSelection(self.RTYPE, 'Output raster type', self.TYPE, 0))
63 self.addParameter(ParameterString(self.EXTRA,
64 'Additional parameters', '-of GTiff', optional=True))
65
66 def processAlgorithm(self, progress):
67 cliPath = '"' + os.path.join(pktoolsUtils.pktoolsPath(), self.cliName()) + '"'
68 commands = [cliPath]
69
70 input=self.getParameterValue(self.INPUT)
71 if input != "":
72 commands.append('-i')
73 commands.append('"' + input + '"')
74
75 filter=self.FILTER_OPTIONS[self.getParameterValue(self.FILTER)]
76 if filter != "none":
77 commands.append("-f")
78 commands.append(filter)
79 if self.getParameterValue(self.DIM) != 0:
80 commands.append("-dim")
81 commands.append(str(self.getParameterValue(self.DIM)))
82
83 if self.TYPE[self.getParameterValue(self.RTYPE)] != "none":
84 commands.append('-ot')
85 commands.append(self.TYPE[self.getParameterValue(self.RTYPE)])
86 output=self.getOutputValue(self.OUTPUT)
87 if output != "":
88 commands.append("-o")
89 commands.append('"' + output + '"')
90
91 extra = str(self.getParameterValue(self.EXTRA))
92 if len(extra) > 0:
93 commands.append(extra)
94
95 pktoolsUtils.runpktools(commands, progress)
qgis.pkfilterdem.pkfilterdem.FILTER
string FILTER
Definition: pkfilterdem.py:47
qgis.pkfilterdem.pkfilterdem.group
group
Definition: pkfilterdem.py:55
qgis.pkfilterdem.pkfilterdem.DIM
string DIM
Definition: pkfilterdem.py:43
qgis.pkfilterdem.pkfilterdem.TYPE
list TYPE
Definition: pkfilterdem.py:45
qgis.pkfilterdem.pkfilterdem.cliName
def cliName(self)
Definition: pkfilterdem.py:50
qgis.pkfilterdem.pkfilterdem.name
name
Definition: pkfilterdem.py:54
qgis.pkfilterdem.pkfilterdem.EXTRA
string EXTRA
Definition: pkfilterdem.py:48
qgis.pkfilterdem.pkfilterdem.RTYPE
string RTYPE
Definition: pkfilterdem.py:44
qgis.pkfilterdem.pkfilterdem.FILTER_OPTIONS
list FILTER_OPTIONS
Definition: pkfilterdem.py:46
qgis.pkfilterdem.pkfilterdem.INPUT
string INPUT
Definition: pkfilterdem.py:41
qgis.pkfilterdem.pkfilterdem.OUTPUT
string OUTPUT
Definition: pkfilterdem.py:42