I have defined xform as a QgsCoordinateTransform to project geographic coordinates.

I can use:

unprojPoint = xform.transform(point, QgsCoordinateTransform.ReverseTransform)

to do the reverse operation, but how can I apply this to a QgsGeometry?

I can do:


alright, but this won't take a direction argument.
I would expect something along the lines of:

line.transform(xform, QgsCoordinateTransform.ReverseTransform)

would work but no luck...

Do I have to set up a new QgsCoordinateTransform to do this?

Note: I am using QGIS 3.0

1 Answer 1


You can do this if you dig into the low-level QgsAbstractGeometry API. Try:

line_data = line.constGet().clone()

    line_data.transform(xform, QgsCoordinateTransform.ReverseTransform)
    # catch transform errors!

transformed_line = QgsGeometry(line_data)
  • Thanks a lot! I hadn't got deep enough obviously! Still, it feels like a miss that you can't apply a direction directly onto a QgsGeometry.
    – YeO
    Commented Apr 10, 2018 at 4:57
  • Sure does, thanks for raising this! Will be fixed by github.com/qgis/QGIS/pull/6774
    – ndawson
    Commented Apr 10, 2018 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.