pktools 2.6.7
Processing Kernel for geospatial data
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qgis.pkextract_grid.pkextract_grid Class Reference
Inheritance diagram for qgis.pkextract_grid.pkextract_grid:
Inheritance graph
[legend]
Collaboration diagram for qgis.pkextract_grid.pkextract_grid:
Collaboration graph
[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 GRID = "GRID"
 
string SRCNODATA = "SRCNODATA"
 
string BNDNODATA = "BNDNODATA"
 
string EXTRA = 'EXTRA'
 
string FORMAT = "FORMAT"
 

Detailed Description

Definition at line 87 of file pkextract_grid.py.

Member Function Documentation

◆ cliName()

def qgis.pkextract_grid.pkextract_grid.cliName (   self)

Definition at line 104 of file pkextract_grid.py.

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

◆ defineCharacteristics()

def qgis.pkextract_grid.pkextract_grid.defineCharacteristics (   self)

Definition at line 107 of file pkextract_grid.py.

107 def defineCharacteristics(self):
108 self.name = "extract regular grid"
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 self.addParameter(ParameterBoolean(self.POLYGON, "Create OGRPolygon as geometry instead of OGRPoint",False))
117 self.addParameter(ParameterNumber(self.BUFFER, "Buffer for calculating statistics for point features",1,25,1))
118 self.addParameter(ParameterNumber(self.GRID, "Cell grid size (in projected units, e.g,. m)",0,1000000,1))
119
120 self.addParameter(ParameterString(self.SRCNODATA, "invalid value(s) for input raster dataset (e.g., 0;255)","none"))
121 self.addParameter(ParameterString(self.BNDNODATA, "Band(s) in input image to check if pixel is valid (e.g., 0;1)","0"))
122 self.addParameter(ParameterString(self.EXTRA, 'Additional parameters', '', optional=True))
123

◆ processAlgorithm()

def qgis.pkextract_grid.pkextract_grid.processAlgorithm (   self,
  progress 
)

Definition at line 124 of file pkextract_grid.py.

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

Member Data Documentation

◆ BNDNODATA

string qgis.pkextract_grid.pkextract_grid.BNDNODATA = "BNDNODATA"
static

Definition at line 99 of file pkextract_grid.py.

◆ BUFFER

string qgis.pkextract_grid.pkextract_grid.BUFFER = "BUFFER"
static

Definition at line 96 of file pkextract_grid.py.

◆ EXTRA

string qgis.pkextract_grid.pkextract_grid.EXTRA = 'EXTRA'
static

Definition at line 100 of file pkextract_grid.py.

◆ FORMAT

string qgis.pkextract_grid.pkextract_grid.FORMAT = "FORMAT"
static

Definition at line 102 of file pkextract_grid.py.

◆ GRID

string qgis.pkextract_grid.pkextract_grid.GRID = "GRID"
static

Definition at line 97 of file pkextract_grid.py.

◆ group

qgis.pkextract_grid.pkextract_grid.group

Definition at line 109 of file pkextract_grid.py.

◆ INPUT

string qgis.pkextract_grid.pkextract_grid.INPUT = "INPUT"
static

Definition at line 89 of file pkextract_grid.py.

◆ name

qgis.pkextract_grid.pkextract_grid.name

Definition at line 108 of file pkextract_grid.py.

◆ OUTPUT

string qgis.pkextract_grid.pkextract_grid.OUTPUT = "OUTPUT"
static

Definition at line 90 of file pkextract_grid.py.

◆ POLYGON

string qgis.pkextract_grid.pkextract_grid.POLYGON = "POLYGON"
static

Definition at line 95 of file pkextract_grid.py.

◆ RULE

string qgis.pkextract_grid.pkextract_grid.RULE = "RULE"
static

Definition at line 94 of file pkextract_grid.py.

◆ RULE_OPTIONS

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

Definition at line 92 of file pkextract_grid.py.

◆ SRCNODATA

string qgis.pkextract_grid.pkextract_grid.SRCNODATA = "SRCNODATA"
static

Definition at line 98 of file pkextract_grid.py.


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