Class: QgsGcpTransformerInterface

An interface for Ground Control Points (GCP) based transformations.

QgsGcpTransformerInterface implementations are able to transform point locations based on a transformation method and a list of GCPs.

Added in version 3.20.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: clone(), method(), minimumGcpCount(), updateParametersFromGcps()

Enums

TransformMethod

Available transformation methods.

Abstract Methods

clone

Clones the transformer, returning a new copy of the transformer with the same parameters as this one.

method

Returns the transformation method.

minimumGcpCount

Returns the minimum number of Ground Control Points (GCPs) required for parameter fitting.

updateParametersFromGcps

Fits transformation parameters using the specified Ground Control Points (GCPs) lists of source and destination coordinates.

Methods

transform

Transforms the point (x, y) from source to destination coordinates.

Static Methods

create

Creates a new QgsGcpTransformerInterface subclass representing the specified transform method.

createFromParameters

Creates a new QgsGcpTransformerInterface subclass representing the specified transform method, initialized using the given lists of source and destination coordinates.

methodToString

Returns a translated string representing the specified transform method.

class qgis.analysis.QgsGcpTransformerInterface[source]

Bases: object

class TransformMethod(*values)

Bases: IntEnum

Available transformation methods.

  • Linear: Linear transform

  • Helmert: Helmert transform

  • PolynomialOrder1: Polynomial order 1

  • PolynomialOrder2: Polyonmial order 2

  • PolynomialOrder3: Polynomial order

  • ThinPlateSpline: Thin plate splines

  • Projective: Projective

  • InvalidTransform: Invalid transform

Helmert = 1
InvalidTransform = 65535
Linear = 0
PolynomialOrder1 = 2
PolynomialOrder2 = 3
PolynomialOrder3 = 4
Projective = 6
ThinPlateSpline = 5
abstract clone(self) QgsGcpTransformerInterface | None[source]

Clones the transformer, returning a new copy of the transformer with the same parameters as this one.

Caller takes ownership of the returned object.

Return type:

Optional[QgsGcpTransformerInterface]

static create(method: QgsGcpTransformerInterface.TransformMethod) QgsGcpTransformerInterface | None[source]

Creates a new QgsGcpTransformerInterface subclass representing the specified transform method.

Caller takes ownership of the returned object.

Parameters:

method (QgsGcpTransformerInterface.TransformMethod)

Return type:

Optional[QgsGcpTransformerInterface]

static createFromParameters(method: QgsGcpTransformerInterface.TransformMethod, sourceCoordinates: Iterable[QgsPointXY], destinationCoordinates: Iterable[QgsPointXY]) QgsGcpTransformerInterface | None[source]

Creates a new QgsGcpTransformerInterface subclass representing the specified transform method, initialized using the given lists of source and destination coordinates.

If the parameters cannot be fit to a transform None will be returned.

Caller takes ownership of the returned object.

Parameters:
Return type:

Optional[QgsGcpTransformerInterface]

abstract method(self) QgsGcpTransformerInterface.TransformMethod[source]

Returns the transformation method.

Return type:

QgsGcpTransformerInterface.TransformMethod

static methodToString(method: QgsGcpTransformerInterface.TransformMethod) str[source]

Returns a translated string representing the specified transform method.

Parameters:

method (QgsGcpTransformerInterface.TransformMethod)

Return type:

str

abstract minimumGcpCount(self) int[source]

Returns the minimum number of Ground Control Points (GCPs) required for parameter fitting.

Return type:

int

transform(self, x: float, y: float, inverseTransform: bool = False)[source]

Transforms the point (x, y) from source to destination coordinates.

If inverseTransform is set to True, the point will be transformed from the destination to the source.

Returns:

True if transformation was successful.

Parameters:
  • x (float)

  • y (float)

  • inverseTransform (bool = False) -> (bool)

abstract updateParametersFromGcps(self, sourceCoordinates: Iterable[QgsPointXY], destinationCoordinates: Iterable[QgsPointXY], invertYAxis: bool = False) bool[source]

Fits transformation parameters using the specified Ground Control Points (GCPs) lists of source and destination coordinates.

If invertYAxis is set to True then the y-axis of source coordinates will be inverted, e.g. to allow for transformation of raster layers with ascending top-to-bottom vertical axis coordinates.

Return type:

bool

Returns:

True on success, False on failure

Parameters:
  • sourceCoordinates (Iterable[QgsPointXY])

  • destinationCoordinates (Iterable[QgsPointXY])

  • invertYAxis (bool = False)