| pktools 2.6.7 Processing Kernel for geospatial data

Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qgis.pksvm.pksvm Class Reference
Inheritance diagram for qgis.pksvm.pksvm:
[legend]
Collaboration diagram for qgis.pksvm.pksvm:
[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 | TRAINING = "TRAINING"
string | ITERATE = "ITERATE"
string | LABEL = "LABEL"
string | GAMMA = "GAMMA"
string | COST = "COST"
string | OUTPUT = "OUTPUT"
string | MASK = "MASK"
string | MSKNODATA = "MSKNODATA"
string | EXTRA = 'EXTRA'

## Detailed Description

Definition at line 40 of file pksvm.py.

## Member Function Documentation

## ◆ cliName()

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

Definition at line 58 of file pksvm.py.

58 def cliName(self):
59 return "pksvm"
60

## ◆ defineCharacteristics()

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

Definition at line 61 of file pksvm.py.

61 def defineCharacteristics(self):
62 self.name = "Support vector machine"
63 self.group = "[pktools] supervised classification"
64 self.addParameter(ParameterRaster(self.INPUT, 'Input layer raster data set',ParameterRaster))
65 self.addParameter(ParameterVector(self.TRAINING, 'Training vector file.'))
66 self.addParameter(ParameterBoolean(self.ITERATE, "Iterate over all layers",True))
67 self.addParameter(ParameterString(self.LABEL, "Attribute name for class label in training vector file","label"))
68 self.addParameter(ParameterNumber(self.GAMMA, "Gamma in kernel function",0,100,1.0))
69 self.addParameter(ParameterNumber(self.COST, "The parameter C of C_SVC",0,100000,1000.0))
70 self.addParameter(ParameterFile(self.MASK, "Mask vector/raster dataset used for classification","None",optional=True))
71 self.addParameter(ParameterString(self.MSKNODATA, "Mask value(s) not to consider for classification (in case of raster mask, e.g., 0;255)","0"))
72 self.addOutput(OutputRaster(self.OUTPUT, "Output raster data set"))
73 self.addParameter(ParameterString(self.EXTRA,
74 'Additional parameters', '-of GTiff', optional=True))
75
76# self.addParameter(ParameterSelection(self.KERNEL_TYPE,"Type of kernel function (linear,polynomial,radial,sigmoid)",self.KERNEL_TYPE_OPTIONS, 2))
77# self.addParameter(ParameterSelection(self.SVM_TYPE,"Type of SVM (C_SVC, nu_SVC,one_class, epsilon_SVR, nu_SVR)",self.SVM_TYPE_OPTIONS, 0))
78

## ◆ processAlgorithm()

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

Definition at line 79 of file pksvm.py.

79 def processAlgorithm(self, progress):
80 cliPath = '"' + os.path.join(pktoolsUtils.pktoolsPath(), self.cliName()) + '"'
81 commands = [cliPath]
82
83 input=self.getParameterValue(self.INPUT)
84 if input != "":
85 commands.append('-i')
86 commands.append('"' + input + '"')
87
88 commands.append('-t')
89 training=self.getParameterValue(self.TRAINING)
90
91 if(str(training).find('|')>0):
92 if self.getParameterValue(self.ITERATE):
93 trainingname=str(training)
94 commands.append(trainingname[:trainingname.find('|')])
95 else:
96 trainingname=str(training).replace("|layername"," -ln")
97 commands.append(trainingname)
98 else:
99 commands.append(training)
100
101 commands.append('-label')
102 commands.append(str(self.getParameterValue(self.LABEL)))
103 # if self.getParameterValue(self.CV):
104 # commands.append("-cv 2")
105 commands.append('-g')
106 commands.append(str(self.getParameterValue(self.GAMMA)))
107 commands.append('-cc')
108 commands.append(str(self.getParameterValue(self.COST)))
109
110 mask = str(self.getParameterValue(self.MASK))
111 if mask != "":
112 commands.append('-m')
113 commands.append(mask)
114 msknodata=str(self.getParameterValue(self.MSKNODATA))
115 msknodataValues = msknodata.split(';')
116 for msknodataValue in msknodataValues:
117 commands.append('-msknodata')
118 commands.append(msknodataValue)
119
120 extra = str(self.getParameterValue(self.EXTRA))
121 if len(extra) > 0:
122 commands.append(extra)
123
124 output=self.getOutputValue(self.OUTPUT)
125 if output != "":
126 commands.append('-o')
127 commands.append('"' + output + '"')
128
129 pktoolsUtils.runpktools(commands, progress)

## Member Data Documentation

## ◆ COST

string qgis.pksvm.pksvm.COST = "COST"
| static

Definition at line 48 of file pksvm.py.

## ◆ EXTRA

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

Definition at line 56 of file pksvm.py.

## ◆ GAMMA

string qgis.pksvm.pksvm.GAMMA = "GAMMA"
| static

Definition at line 47 of file pksvm.py.

## ◆ group

qgis.pksvm.pksvm.group

Definition at line 63 of file pksvm.py.

## ◆ INPUT

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

Definition at line 42 of file pksvm.py.

## ◆ ITERATE

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

Definition at line 44 of file pksvm.py.

## ◆ LABEL

string qgis.pksvm.pksvm.LABEL = "LABEL"
| static

Definition at line 45 of file pksvm.py.

## ◆ MASK

string qgis.pksvm.pksvm.MASK = "MASK"
| static

Definition at line 50 of file pksvm.py.

## ◆ MSKNODATA

string qgis.pksvm.pksvm.MSKNODATA = "MSKNODATA"
| static

Definition at line 51 of file pksvm.py.

## ◆ name

qgis.pksvm.pksvm.name

Definition at line 62 of file pksvm.py.

## ◆ OUTPUT

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

Definition at line 49 of file pksvm.py.

## ◆ TRAINING

string qgis.pksvm.pksvm.TRAINING = "TRAINING"
| static

Definition at line 43 of file pksvm.py.

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

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