| pktools 2.6.7 Processing Kernel for geospatial data

Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qgis.pkextract.pkextract Class Reference
Inheritance diagram for qgis.pkextract.pkextract:
[legend]
Collaboration diagram for qgis.pkextract.pkextract:
[legend]

## Public Member Functions
def | cliName (self)
def | defineCharacteristics (self)
def | processAlgorithm (self, progress)
Public Member Functions inherited from qgis.pktoolsAlgorithm.pktoolsAlgorithm
def | getIcon (self)
def | checkBeforeOpeningParametersDialog (self)
def | help (self)

## Public Attributes
| name
| group

## Static Public Attributes
string | INPUT = "INPUT"
string | SAMPLE = "SAMPLE"
string | ITERATE = "ITERATE"
string | OUTPUT = "OUTPUT"
list | RULE_OPTIONS = ['centroid', 'point', 'mean', 'proportion', 'count', 'min', 'max', 'mode', 'sum', 'median', 'stdev', 'percentile']
string | RULE = "RULE"
string | POLYGON = "POLYGON"
string | BUFFER = "BUFFER"
string | SRCNODATA = "SRCNODATA"
string | BNDNODATA = "BNDNODATA"
string | EXTRA = 'EXTRA'
string | FORMAT = "FORMAT"

## Detailed Description

Definition at line 87 of file pkextract.py.

## Member Function Documentation

## ◆ cliName()

def qgis.pkextract.pkextract.cliName | ( |  | self | ) |

Definition at line 106 of file pkextract.py.

106 def cliName(self):
107 return "pkextractogr"
108

## ◆ defineCharacteristics()

def qgis.pkextract.pkextract.defineCharacteristics | ( |  | self | ) |

Definition at line 109 of file pkextract.py.

109 def defineCharacteristics(self):
110 self.name = "extract vector sample from raster"
111 self.group = "[pktools] raster/vector"
112 self.addParameter(ParameterRaster(self.INPUT, 'Input raster data set'))
113 self.addParameter(ParameterVector(self.SAMPLE, 'Sample vector data set'))
114 self.addParameter(ParameterBoolean(self.ITERATE, "Iterate over all layers",True))
115 self.addParameter(ParameterSelection(self.RULE,"extraction rule",self.RULE_OPTIONS, 0))
116
117 self.addOutput(OutputVector(self.OUTPUT, 'Output vector data set'))
118 self.addParameter(ParameterSelection(self.FORMAT,
119 'Destination Format', FORMATS))
120
121 self.addParameter(ParameterBoolean(self.POLYGON, "Create OGRPolygon as geometry instead of OGRPoint",False))
122 self.addParameter(ParameterNumber(self.BUFFER, "Buffer for calculating statistics for point features",0,19,0))
123 self.addParameter(ParameterString(self.SRCNODATA, "invalid value(s) for input raster dataset (e.g., 0;255)","none"))
124 self.addParameter(ParameterString(self.BNDNODATA, "Band(s) in input image to check if pixel is valid (e.g., 0;1)","0"))
125
126 self.addParameter(ParameterString(self.EXTRA,
127 'Additional parameters', '', optional=True))
128

## ◆ processAlgorithm()

def qgis.pkextract.pkextract.processAlgorithm | ( |  | self,
|  |  | progress
| ) |  |

Definition at line 129 of file pkextract.py.

129 def processAlgorithm(self, progress):
130 cliPath = '"' + os.path.join(pktoolsUtils.pktoolsPath(), self.cliName()) + '"'
131 commands = [cliPath]
132
133 input=self.getParameterValue(self.INPUT)
134 commands.append('-i')
135 commands.append('"' + input + '"')
136
137 sample=self.getParameterValue(self.SAMPLE)
138 if self.getParameterValue(self.ITERATE):
139 if str(sample).find('|')>0:
140 samplename=str(sample)[:str(sample).find('|')]
141 else:
142 samplename=str(sample)
143 else:
144 samplename=str(sample).replace("|layername"," -ln")
145 commands.append('-s')
146 commands.append(samplename)
147
148 if self.getParameterValue(self.POLYGON):
149 commands.append("-polygon")
150
151 commands.append("-r")
152 commands.append(self.RULE_OPTIONS[self.getParameterValue(self.RULE)])
153
154 output = self.getOutputFromName(self.OUTPUT)
155 outFile = output.value
156 formatIdx = self.getParameterValue(self.FORMAT)
157 outFormat = '"' + FORMATS[formatIdx] + '"'
158 commands.append('-f')
159 commands.append(outFormat)
160 ext = EXTS[formatIdx]
161 if not outFile.endswith(ext):
162 outFile += ext
163 output.value = outFile
164 commands.append('-o')
165 commands.append('"' + outFile + '"')
166
167 buffer=self.getParameterValue(self.BUFFER)
168 if buffer > 1:
169 commands.append("-buf")
170 commands.append(str(buffer))
171
172 srcnodata=self.getParameterValue(self.SRCNODATA)
173 if srcnodata != "none":
174 srcnodataValues = srcnodata.split(';')
175 for srcnodataValue in srcnodataValues:
176 commands.append('-srcnodata')
177 commands.append(srcnodataValue)
178 bndnodata=self.getParameterValue(self.BNDNODATA)
179 bndnodataValues = bndnodata.split(';')
180 for bndnodataValue in bndnodataValues:
181 commands.append('-bndnodata')
182 commands.append(bndnodataValue)
183
184 extra = str(self.getParameterValue(self.EXTRA))
185 if len(extra) > 0:
186 commands.append(extra)
187
188 pktoolsUtils.runpktools(commands, progress)

## Member Data Documentation

## ◆ BNDNODATA

string qgis.pkextract.pkextract.BNDNODATA = "BNDNODATA"
| static

Definition at line 100 of file pkextract.py.

## ◆ BUFFER

string qgis.pkextract.pkextract.BUFFER = "BUFFER"
| static

Definition at line 98 of file pkextract.py.

## ◆ EXTRA

string qgis.pkextract.pkextract.EXTRA = 'EXTRA'
| static

Definition at line 102 of file pkextract.py.

## ◆ FORMAT

string qgis.pkextract.pkextract.FORMAT = "FORMAT"
| static

Definition at line 104 of file pkextract.py.

## ◆ group

qgis.pkextract.pkextract.group

Definition at line 111 of file pkextract.py.

## ◆ INPUT

string qgis.pkextract.pkextract.INPUT = "INPUT"
| static

Definition at line 89 of file pkextract.py.

## ◆ ITERATE

string qgis.pkextract.pkextract.ITERATE = "ITERATE"
| static

Definition at line 91 of file pkextract.py.

## ◆ name

qgis.pkextract.pkextract.name

Definition at line 110 of file pkextract.py.

## ◆ OUTPUT

string qgis.pkextract.pkextract.OUTPUT = "OUTPUT"
| static

Definition at line 92 of file pkextract.py.

## ◆ POLYGON

string qgis.pkextract.pkextract.POLYGON = "POLYGON"
| static

Definition at line 97 of file pkextract.py.

## ◆ RULE

string qgis.pkextract.pkextract.RULE = "RULE"
| static

Definition at line 96 of file pkextract.py.

## ◆ RULE_OPTIONS

list qgis.pkextract.pkextract.RULE_OPTIONS = ['centroid', 'point', 'mean', 'proportion', 'count', 'min', 'max', 'mode', 'sum', 'median', 'stdev', 'percentile']
| static

Definition at line 94 of file pkextract.py.

## ◆ SAMPLE

string qgis.pkextract.pkextract.SAMPLE = "SAMPLE"
| static

Definition at line 90 of file pkextract.py.

## ◆ SRCNODATA

string qgis.pkextract.pkextract.SRCNODATA = "SRCNODATA"
| static

Definition at line 99 of file pkextract.py.

The documentation for this class was generated from the following file:

- /tmp/slackdce/slackrepo.NvCr9x/build_pktools/PKTOOLS-2.6.7.6/qgis/pkextract.py