Class: QgsClassificationMethod¶
- class qgis.core.QgsClassificationMethod¶
Bases:
sip.wrapper
QgsClassificationMethod
is an abstract class for implementations of classification methodsSee also
New in version 3.10.
QgsClassificationMethod(properties: Union[QgsClassificationMethod.MethodProperties, QgsClassificationMethod.MethodProperty] = QgsClassificationMethod.NoFlag, codeComplexity: int = 1) Creates a classification method.
- Parameters
properties – The properties of the implemented method
codeComplexity – as the exponent in the big O notation
QgsClassificationMethod(
QgsClassificationMethod
)Methods
This will calculate the classes for a given layer to define the classes.
Returns a clone of the method.
Code complexity as the exponent in Big O notation
Reads the DOM element and return a new classification method from it
The icon of the method
The id of the method as saved in the project, must be unique in registry
Returns the label for a range
Returns the format of the label for the classes
Returns the precision for the formatting of the labels
Returns if the trailing 0 are trimmed in the label
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint Does not put a break on the symmetryPoint.
The readable and translate name of the method
Returns the parameter from its name
Returns the list of parameters
Returns the values of the processing parameters.
Transforms a list of classes to a list of breaks
Reads extra information to apply it to the method
Saves the method to a DOM element and return it
Defines the format of the labels for the classes, using %1 and %2 for the bounds
Defines the precision for the formatting of the labels
Defines if the trailing 0 are trimmed in the label
Defines the values of the additional parameters
Defines if the symmetric mode is enables and configures its parameters.
Returns if the method supports symmetric calculation
Returns if the symmetric mode is enabled
Returns if the symmetric mode is astride if
True
, it will remove the symmetry point break so that the 2 classes form only oneReturns the symmetry point for symmetric mode
Returns if the method requires values to calculate the classes If not, bounds are sufficient
Writes extra information about the method
Attributes
- class ClassPosition¶
Bases:
int
- Inner = 1¶
- LowerBound = 0¶
- MAX_PRECISION = 15¶
- MIN_PRECISION = -6¶
- class MethodProperties¶
- class MethodProperties(Union[QgsClassificationMethod.MethodProperties, QgsClassificationMethod.MethodProperty]) None
- class MethodProperties(QgsClassificationMethod.MethodProperties) None
Bases:
sip.wrapper
- class MethodProperty¶
Bases:
int
- NoFlag = 0¶
- SymmetricModeAvailable = 4¶
- UpperBound = 2¶
- ValuesNotRequired = 2¶
- classes(self, layer: QgsVectorLayer, expression: str, nclasses: int) List[QgsClassificationRange] ¶
This will calculate the classes for a given layer to define the classes.
- Parameters
layer (QgsVectorLayer) – The vector layer
expression (str) – The name of the field on which the classes are calculated
nclasses (int) – The number of classes to be returned
classes(self, values: Iterable[float], nclasses: int) -> List[QgsClassificationRange] This will calculate the classes for a list of values.
- Parameters
values – The list of values
nclasses – The number of classes to be returned
classes(self, minimum: float, maximum: float, nclasses: int) -> List[QgsClassificationRange] This will calculate the classes for defined bounds without any values.
Warning
If the method implementation requires values, this will return an empty list.
- Parameters
minimum – The minimum value for the breaks
maximum – The maximum value for the breaks
nclasses – The number of classes to be returned
- Return type
List[QgsClassificationRange]
- clone(self) QgsClassificationMethod ¶
Returns a clone of the method. Implementation can take advantage of copyBase method which copies the parameters of the base class
- Return type
- codeComplexity(self) int ¶
Code complexity as the exponent in Big O notation
- Return type
int
- create(element: QDomElement, context: QgsReadWriteContext) QgsClassificationMethod ¶
Reads the DOM element and return a new classification method from it
- Parameters
element (QDomElement) – the DOM element
context (QgsReadWriteContext) – the read/write context
- Return type
- icon(self) QIcon ¶
The icon of the method
- Return type
QIcon
- id(self) str ¶
The id of the method as saved in the project, must be unique in registry
- Return type
str
- labelForRange(self, lowerValue: float, upperValue: float, position: QgsClassificationMethod.ClassPosition = QgsClassificationMethod.Inner) str ¶
Returns the label for a range
labelForRange(self, range:
QgsRendererRange
, position: QgsClassificationMethod.ClassPosition = QgsClassificationMethod.Inner) -> str Returns the label for a range- Parameters
lowerValue (float) –
upperValue (float) –
position (QgsClassificationMethod.ClassPosition = QgsClassificationMethod.Inner) –
- Return type
str
- labelFormat(self) str ¶
Returns the format of the label for the classes
- Return type
str
- labelPrecision(self) int ¶
Returns the precision for the formatting of the labels
- Return type
int
- labelTrimTrailingZeroes(self) bool ¶
Returns if the trailing 0 are trimmed in the label
- Return type
bool
- makeBreaksSymmetric(breaks: Iterable[float], symmetryPoint: float, astride: bool) List[float] ¶
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint Does not put a break on the symmetryPoint. This is done before.
- Parameters
breaks (Iterable[float]) – The breaks of an already-done classification
symmetryPoint (float) – The point around which we want a symmetry
astride (bool) – A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
- Return type
List[float]
- name(self) str ¶
The readable and translate name of the method
- Return type
str
- parameterDefinition(self, parameterName: str) QgsProcessingParameterDefinition ¶
Returns the parameter from its name
New in version 3.12.
- Parameters
parameterName (str) –
- Return type
- parameterDefinitions(self) List[QgsProcessingParameterDefinition] ¶
Returns the list of parameters
New in version 3.12.
- Return type
- parameterValues(self) Dict[str, Any] ¶
Returns the values of the processing parameters. One could use
QgsProcessingParameters
.parameterAsXxxx to retrieve the actual value of a parameter.New in version 3.12.
- Return type
Dict[str, Any]
- rangesToBreaks(classes: Iterable[QgsClassificationRange]) List[float] ¶
Transforms a list of classes to a list of breaks
- Parameters
classes (Iterable[QgsClassificationRange]) –
- Return type
List[float]
- readXml(self, element: QDomElement, context: QgsReadWriteContext)¶
Reads extra information to apply it to the method
- Parameters
element (QDomElement) –
context (QgsReadWriteContext) –
- save(self, doc: QDomDocument, context: QgsReadWriteContext) QDomElement ¶
Saves the method to a DOM element and return it
- Parameters
doc (QDomDocument) – the DOM document
context (QgsReadWriteContext) – the read/write context
- Return type
QDomElement
- setLabelFormat(self, format: str)¶
Defines the format of the labels for the classes, using %1 and %2 for the bounds
- Parameters
format (str) –
- setLabelPrecision(self, labelPrecision: int)¶
Defines the precision for the formatting of the labels
- Parameters
labelPrecision (int) –
- setLabelTrimTrailingZeroes(self, trimTrailingZeroes: bool)¶
Defines if the trailing 0 are trimmed in the label
- Parameters
trimTrailingZeroes (bool) –
- setParameterValues(self, values: Dict[str, Any])¶
Defines the values of the additional parameters
New in version 3.12.
- Parameters
values (Dict[str) –
- setSymmetricMode(self, enabled: bool, symmetryPoint: float = 0, symmetryAstride: bool = False)¶
Defines if the symmetric mode is enables and configures its parameters. If the symmetric mode is not available in the current implementation, calling this method has no effect.
- Parameters
enabled (bool) – if the symmetric mode is enabled
symmetryPoint (float = 0) – the value of the symmetry point
symmetryAstride (bool = False) – if
True
, it will remove the symmetry point break so that the 2 classes form only one
- symmetricModeAvailable(self) bool ¶
Returns if the method supports symmetric calculation
- Return type
bool
- symmetricModeEnabled(self) bool ¶
Returns if the symmetric mode is enabled
- Return type
bool
- symmetryAstride(self) bool ¶
Returns if the symmetric mode is astride if
True
, it will remove the symmetry point break so that the 2 classes form only one- Return type
bool
- symmetryPoint(self) float ¶
Returns the symmetry point for symmetric mode
- Return type
float
- valuesRequired(self) bool ¶
Returns if the method requires values to calculate the classes If not, bounds are sufficient
- Return type
bool
- writeXml(self, element: QDomElement, context: QgsReadWriteContext)¶
Writes extra information about the method
- Parameters
element (QDomElement) –
context (QgsReadWriteContext) –