| pktools 2.6.7 Processing Kernel for geospatial data

Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qgis.pkextract_random.pkextract_random Class Reference
Inheritance diagram for qgis.pkextract_random.pkextract_random:
[legend]
Collaboration diagram for qgis.pkextract_random.pkextract_random:
[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 | OUTPUT = "OUTPUT"
list | RULE_OPTIONS = ['centroid', 'point', 'mean', 'proportion', 'custom', 'min', 'max', 'mode', 'sum', 'median', 'stdev', 'percentile']
string | RULE = "RULE"
string | POLYGON = "POLYGON"
string | BUFFER = "BUFFER"
string | RANDOM = "RANDOM"
string | SRCNODATA = "SRCNODATA"
string | BNDNODATA = "BNDNODATA"
string | EXTRA = 'EXTRA'
string | FORMAT = "FORMAT"

## Detailed Description

Definition at line 87 of file pkextract_random.py.

## Member Function Documentation

## ◆ cliName()

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

Definition at line 104 of file pkextract_random.py.

104 def cliName(self):
105 return "pkextractogr"
106

## ◆ defineCharacteristics()

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

Definition at line 107 of file pkextract_random.py.

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

## ◆ processAlgorithm()

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

Definition at line 126 of file pkextract_random.py.

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

## Member Data Documentation

## ◆ BNDNODATA

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

Definition at line 99 of file pkextract_random.py.

## ◆ BUFFER

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

Definition at line 96 of file pkextract_random.py.

## ◆ EXTRA

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

Definition at line 100 of file pkextract_random.py.

## ◆ FORMAT

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

Definition at line 102 of file pkextract_random.py.

## ◆ group

qgis.pkextract_random.pkextract_random.group

Definition at line 109 of file pkextract_random.py.

## ◆ INPUT

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

Definition at line 89 of file pkextract_random.py.

## ◆ name

qgis.pkextract_random.pkextract_random.name

Definition at line 108 of file pkextract_random.py.

## ◆ OUTPUT

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

Definition at line 90 of file pkextract_random.py.

## ◆ POLYGON

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

Definition at line 95 of file pkextract_random.py.

## ◆ RANDOM

string qgis.pkextract_random.pkextract_random.RANDOM = "RANDOM"
| static

Definition at line 97 of file pkextract_random.py.

## ◆ RULE

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

Definition at line 94 of file pkextract_random.py.

## ◆ RULE_OPTIONS

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

Definition at line 92 of file pkextract_random.py.

## ◆ SRCNODATA

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

Definition at line 98 of file pkextract_random.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_random.py