[QGIS-Developer] PyQgis QgsCoordinateTransform constructor?

Nyall Dawson nyall.dawson at gmail.com
Fri Dec 22 20:36:15 PST 2017

On 22 December 2017 at 17:44, Richard Duivenvoorde <rdmailings at duif.net> wrote:
> While the api
> https://qgis.org/api/classQgsCoordinateTransform.html#a8c036726885d51e9fdfe1478a063dfcd
> still notes this constructor?
> Do I miss info? Or is something wrong with my sip stuff?

Nope, as Denis has noted those website API docs are out of date and
should be updated... maybe something is broken in the script to do
this? Note that https://github.com/qgis/QGIS/pull/5944/files expands
the dox based on this discussion.

> What is plan/status to show this (also?) in the qgis.org/api docs?
> I know there has been talk about it.
> Would be a shame to show this very helpful documentation (thanks to the
> writers) only in code?

Denis has been doing fantastic work lately in auto converting the c++
doxygen into standard Python docs. I'd love to see us add this to our
website too. I'm sure this would be another great feature to launch
with 3.0 - real Python documentation for our classes!

> Just for reference, I think (but please correct me if otherwise) that
> for plugins this is then the easiest one?
> crsTransform = QgsCoordinateTransform(crs2, crs, QgsProject.instance())
> as even with a non saved project this will provide the necessary
> QgsCoordinateTransformContext ?

Mostly, but depends on the context. There's some code paths where the
project is explicitly available and that project should be used
instead of the catch-all "QgsProject.instance()" call. E.g. a
processing algorithm should use the project specified in the
QgsProcessingContext, not QgsProject.instance(). That's also why I
don't think auto-inserting this argument for Python is appropriate.


More information about the QGIS-Developer mailing list