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
Available transformation methods. |
Abstract Methods
Clones the transformer, returning a new copy of the transformer with the same parameters as this one. |
|
Returns the transformation method. |
|
Returns the minimum number of Ground Control Points (GCPs) required for parameter fitting. |
|
Fits transformation parameters using the specified Ground Control Points (GCPs) lists of source and destination coordinates. |
Methods
Transforms the point (x, y) from source to destination coordinates. |
Static Methods
Creates a new |
|
Creates a new |
|
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 transformHelmert
: Helmert transformPolynomialOrder1
: Polynomial order 1PolynomialOrder2
: Polyonmial order 2PolynomialOrder3
: Polynomial orderThinPlateSpline
: Thin plate splinesProjective
: ProjectiveInvalidTransform
: 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 transformmethod
.Caller takes ownership of the returned object.
- Parameters:
- 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 transformmethod
, 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:
sourceCoordinates (Iterable[QgsPointXY])
destinationCoordinates (Iterable[QgsPointXY])
- Return type:
Optional[QgsGcpTransformerInterface]
- abstract method(self) QgsGcpTransformerInterface.TransformMethod [source]¶
Returns the transformation method.
- Return type:
- static methodToString(method: QgsGcpTransformerInterface.TransformMethod) str [source]¶
Returns a translated string representing the specified transform
method
.- Parameters:
- 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 toTrue
, 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 toTrue
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)