4***************************************************************************
8 Copyright : (C) 2015 by Pieter Kempeneers
9 Email : kempenep at gmail dot com
10***************************************************************************
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. *
17***************************************************************************
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$'
27from pktoolsUtils import pktoolsUtils
28from pktoolsAlgorithm import pktoolsAlgorithm
29from processing.core.parameters import ParameterMultipleInput
30from processing.core.parameters import ParameterRaster
31from processing.core.parameters import ParameterFile
32from processing.core.outputs import OutputRaster
33from processing.core.parameters import ParameterSelection
34from processing.core.parameters import ParameterNumber
35from processing.core.parameters import ParameterString
36from processing.core.parameters import ParameterBoolean
37from processing.core.parameters import ParameterExtent
39class pklas2img(pktoolsAlgorithm):
43 ATTRIBUTE_OPTIONS = [
"z",
"intensity",
"return",
"nreturn"]
44 COMPOSITE_OPTIONS = [
"last",
"min",
"max",
"absmin",
"absmax",
"median",
"mean",
"sum",
"first",
"profile",
"percentile",
"height",
"values",
"percentile",
"number"]
45 FILTER_OPTIONS = [
"all",
"first",
"last",
"single",
"multiple"]
47 ATTRIBUTE =
"ATTRIBUTE"
48 COMPOSITE =
"COMPOSITE"
51 PERCENTILE =
"PERCENTILE"
57 TYPE = [
'Float32',
'Byte',
'Int16',
'UInt16',
'UInt32',
'Int32',
'Float64',
'CInt16',
'CInt32',
'CFloat32',
'CFloat64']
63 def defineCharacteristics(self):
64 self.
name =
"Create raster dataset from LAS(Z) data point cloud(s)"
65 self.
group =
"[pktools] LiDAR"
67 self.addParameter(ParameterFile(self.
INPUT,
"Input LAS(Z) data set(s)",
False,
False))
72 self.addOutput(OutputRaster(self.
OUTPUT,
"Output raster data set"))
73 self.addParameter(ParameterSelection(self.
RTYPE,
'Output raster type', self.
TYPE, 0))
74 self.addParameter(ParameterNumber(self.
PERCENTILE,
"Percentile value used for rule percentile",0.0,100.0,95))
75 self.addParameter(ParameterNumber(self.
DX,
"Output resolution in x",0.0,
None,1.0))
76 self.addParameter(ParameterNumber(self.
DY,
"Output resolution in y",0.0,
None,1.0))
79 self.addParameter(ParameterNumber(self.
NODATA,
"nodata value to put in image",0,
None,0))
80 self.addParameter(ParameterString(self.
EXTRA,
81 'Additional parameters',
'-of GTiff', optional=
True))
83 def processAlgorithm(self, progress):
84 cliPath =
'"' + os.path.join(pktoolsUtils.pktoolsPath(), self.
cliName()) +
'"'
87 input=self.getParameterValue(self.
INPUT)
88 inputFiles = input.split(
';')
89 for inputFile
in inputFiles:
91 commands.append(
'"' + inputFile +
'"')
93 if self.
TYPE[self.getParameterValue(self.
RTYPE)] !=
"none":
94 commands.append(
'-ot')
95 commands.append(self.
TYPE[self.getParameterValue(self.
RTYPE)])
97 output=self.getOutputValue(self.
OUTPUT)
100 commands.append(
'"' + output +
'"')
102 commands.append(
"-n")
104 commands.append(
"-comp")
106 commands.append(
"-fir")
108 if self.getParameterValue(self.
DX) != 0:
109 commands.append(
"-dx")
110 commands.append(str(self.getParameterValue(self.
DX)))
111 if self.getParameterValue(self.
DY) != 0:
112 commands.append(
"-dy")
113 commands.append(str(self.getParameterValue(self.
DY)))
124 commands.append(
'-nodata')
125 commands.append(str(self.getParameterValue(self.
NODATA)))
127 extra = str(self.getParameterValue(self.
EXTRA))
129 commands.append(extra)
131 pktoolsUtils.runpktools(commands, progress)