pktools 2.6.7
Processing Kernel for geospatial data
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qgis.pkcrop.pkcrop Class Reference
Inheritance diagram for qgis.pkcrop.pkcrop:
Inheritance graph
[legend]
Collaboration diagram for qgis.pkcrop.pkcrop:
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"
 
string DX = "DX"
 
string DY = "DY"
 
string PROJWIN = 'PROJWIN'
 
string BAND = "BAND"
 
string NODATA = "NODATA"
 
list RESAMPLE_OPTIONS = ['near', 'bilinear']
 
string RESAMPLE = "RESAMPLE"
 
string RTYPE = 'RTYPE'
 
list TYPE = ['none', 'Byte','Int16','UInt16','UInt32','Int32','Float32','Float64','CInt16','CInt32','CFloat32','CFloat64']
 
string EXTRA = 'EXTRA'
 

Detailed Description

Definition at line 38 of file pkcrop.py.

Member Function Documentation

◆ cliName()

def qgis.pkcrop.pkcrop.cliName (   self)

Definition at line 53 of file pkcrop.py.

53 def cliName(self):
54 return "pkcrop"
55

◆ defineCharacteristics()

def qgis.pkcrop.pkcrop.defineCharacteristics (   self)

Definition at line 56 of file pkcrop.py.

56 def defineCharacteristics(self):
57 self.name = "crop raster datasets"
58 self.group = "[pktools] raster"
59 self.addParameter(ParameterMultipleInput(self.INPUT, 'Input layer raster data set',ParameterMultipleInput.TYPE_RASTER))
60 self.addOutput(OutputRaster(self.OUTPUT, "Output raster data set"))
61 self.addParameter(ParameterSelection(self.RTYPE, 'Output raster type (leave as none to keep original type)', self.TYPE, 0))
62 self.addParameter(ParameterNumber(self.DX, "Output resolution in x (leave 0 for no change)",0.0,None,0.0))
63 self.addParameter(ParameterNumber(self.DY, "Output resolution in y (leave 0 for no change)",0.0,None,0.0))
64 self.addParameter(ParameterExtent(self.PROJWIN,
65 'Georeferenced boundingbox'))
66 self.addParameter(ParameterString(self.NODATA, "invalid value(s) for input raster dataset (e.g., 0;255)","none"))
67 self.addParameter(ParameterString(self.BAND, "Band(s) in input image to crop, e.g., 0;1;2 (leave empty to retain all bands)",'', optional=True))
68 self.addParameter(ParameterSelection(self.RESAMPLE,"resampling method",self.RESAMPLE_OPTIONS, 0))
69 self.addParameter(ParameterString(self.EXTRA,
70 'Additional parameters', '-of GTiff', optional=True))
71

◆ processAlgorithm()

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

Definition at line 72 of file pkcrop.py.

72 def processAlgorithm(self, progress):
73 cliPath = '"' + os.path.join(pktoolsUtils.pktoolsPath(), self.cliName()) + '"'
74 commands = [cliPath]
75
76 input=self.getParameterValue(self.INPUT)
77 inputFiles = input.split(';')
78 for inputFile in inputFiles:
79 commands.append('-i')
80 commands.append('"' + inputFile + '"')
81
82 if self.TYPE[self.getParameterValue(self.RTYPE)] != "none":
83 commands.append('-ot')
84 commands.append(self.TYPE[self.getParameterValue(self.RTYPE)])
85 output=self.getOutputValue(self.OUTPUT)
86 if output != "":
87 commands.append("-o")
88 commands.append('"' + output + '"')
89 if self.getParameterValue(self.DX) != 0:
90 commands.append("-dx")
91 commands.append(str(self.getParameterValue(self.DX)))
92 if self.getParameterValue(self.DY) != 0:
93 commands.append("-dy")
94 commands.append(str(self.getParameterValue(self.DY)))
95
96 projwin = str(self.getParameterValue(self.PROJWIN))
97 if(str(projwin).find(',')>0):
98 regionCoords = projwin.split(',')
99 commands.append('-ulx')
100 commands.append(regionCoords[0])
101 commands.append('-uly')
102 commands.append(regionCoords[3])
103 commands.append('-lrx')
104 commands.append(regionCoords[1])
105 commands.append('-lry')
106 commands.append(regionCoords[2])
107
108 nodata=self.getParameterValue(self.NODATA)
109 if nodata != "none":
110 nodataValues = nodata.split(';')
111 for nodataValue in nodataValues:
112 commands.append('-nodata')
113 commands.append(nodataValue)
114
115 band=self.getParameterValue(self.BAND)
116 if band != '':
117 bandValues = band.split(';')
118 for bandValue in bandValues:
119 commands.append('-b')
120 commands.append(bandValue)
121 commands.append("-r")
122 commands.append(self.RESAMPLE_OPTIONS[self.getParameterValue(self.RESAMPLE)])
123
124 extra = str(self.getParameterValue(self.EXTRA))
125 if len(extra) > 0:
126 commands.append(extra)
127
128 pktoolsUtils.runpktools(commands, progress)

Member Data Documentation

◆ BAND

string qgis.pkcrop.pkcrop.BAND = "BAND"
static

Definition at line 45 of file pkcrop.py.

◆ DX

string qgis.pkcrop.pkcrop.DX = "DX"
static

Definition at line 42 of file pkcrop.py.

◆ DY

string qgis.pkcrop.pkcrop.DY = "DY"
static

Definition at line 43 of file pkcrop.py.

◆ EXTRA

string qgis.pkcrop.pkcrop.EXTRA = 'EXTRA'
static

Definition at line 51 of file pkcrop.py.

◆ group

qgis.pkcrop.pkcrop.group

Definition at line 58 of file pkcrop.py.

◆ INPUT

string qgis.pkcrop.pkcrop.INPUT = "INPUT"
static

Definition at line 40 of file pkcrop.py.

◆ name

qgis.pkcrop.pkcrop.name

Definition at line 57 of file pkcrop.py.

◆ NODATA

string qgis.pkcrop.pkcrop.NODATA = "NODATA"
static

Definition at line 46 of file pkcrop.py.

◆ OUTPUT

string qgis.pkcrop.pkcrop.OUTPUT = "OUTPUT"
static

Definition at line 41 of file pkcrop.py.

◆ PROJWIN

string qgis.pkcrop.pkcrop.PROJWIN = 'PROJWIN'
static

Definition at line 44 of file pkcrop.py.

◆ RESAMPLE

string qgis.pkcrop.pkcrop.RESAMPLE = "RESAMPLE"
static

Definition at line 48 of file pkcrop.py.

◆ RESAMPLE_OPTIONS

list qgis.pkcrop.pkcrop.RESAMPLE_OPTIONS = ['near', 'bilinear']
static

Definition at line 47 of file pkcrop.py.

◆ RTYPE

string qgis.pkcrop.pkcrop.RTYPE = 'RTYPE'
static

Definition at line 49 of file pkcrop.py.

◆ TYPE

list qgis.pkcrop.pkcrop.TYPE = ['none', 'Byte','Int16','UInt16','UInt32','Int32','Float32','Float64','CInt16','CInt32','CFloat32','CFloat64']
static

Definition at line 50 of file pkcrop.py.


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