[Qgis-user] QgsCoordinateTransform does not get initialized in Qgis 2.10

Tudorache, Marian Marian.Tudorache at navcanada.ca
Wed Mar 8 12:58:02 PST 2017


Hi,

I have an issue with coordinate transformation when I use QgsCoordinateTransform class.
I want to transform a point given on ul_stereographic (see the projection string) to lat and long on GRS80 (see the grs80 string).

The point is
czul_old_ddl = qgis.core.QgsPoint(177309.9337868, -893161.8040887)
After I run the below script I get
Transformed point pt1, pt2: (177310,-893162) (-493719,-701640)
So my point supposed to be in lat and long using decimal degree format.
I verified ",xform.isInitialised() and it is False.

So why QgsCoordinateTransform does not get initialized?
I am using QGIS 2.10.

Thank you,
Marian


ul_stereographic = "+proj=sterea +lat_0=53.5 +lon_0=-76.0 +k=0.9996 +x_0=0.0 +y_0=0.0 +a=6378137 +b=6381816.160744 +ellps=GRS80 +datum=GRS80 +units=m +no_defs"
grs80 = "+proj=longlat +ellps=GRS80 +units=degrees"

print "ul_stereographic ", ul_stereographic
print "grs80 ", grs80

crsSrc = qgis.core.QgsCoordinateReferenceSystem()
crsSrc.createFromProj4(ul_stereographic)
crsDest = qgis.core.QgsCoordinateReferenceSystem()
crsDest.createFromProj4(grs80)

xform = qgis.core.QgsCoordinateTransform()
xform.setSourceCrs(crsSrc)
xform.setDestCRS(crsDest)

czul_old_ddl = qgis.core.QgsPoint(177309.9337868, -893161.8040887)
czul_new_ddl = qgis.core.QgsPoint(-493718.78427, -701639.769759)

pt1 = xform.transform(czul_old_ddl, qgis.core.QgsCoordinateTransform.ForwardTransform)
pt2 = xform.transform(czul_new_ddl, qgis.core.QgsCoordinateTransform.ForwardTransform)
print "Transformed point pt1, pt2:", pt1, pt2



print "QGIS CRS ID:", crsSrc.srsid(), crsDest.srsid()
print "Description:", crsSrc.description(), " - ", crsDest.description()
print "Projection Acronym:", crsSrc.projectionAcronym(), " - ", crsDest.projectionAcronym()
print "Ellipsoid Acronym:", crsSrc.ellipsoidAcronym(), " - ", crsDest.ellipsoidAcronym()
#print "Proj4 String:", crsSrc.toProj4(), " - ", crsDest.toProj4()
print "Is geographic:", crsSrc.geographicFlag(), " - ", crsDest.geographicFlag()
print "Map units:", crsSrc.mapUnits(), " - ", crsDest.mapUnits()

print "xform.isInitialised() ",xform.isInitialised()

print "xform.destCRS() ",xform.destCRS()


#results
#ul_stereographic  +proj=sterea +lat_0=53.5 +lon_0=-76.0 +k=0.9996 +x_0=0.0 +y_0=0.0 +a=6378137 +b=6381816.160744 +units=m +no_defs
#grs80  +proj=longlat +ellps=GRS80 +units=degrees
#Transformed point pt1, pt2: (177310,-893162) (-493719,-701640)
#QGIS CRS ID: 0 0
#Description:   -
#Projection Acronym: sterea  -  longlat
#Ellipsoid Acronym:   -  GRS80
#Is geographic: False  -  False
#Map units: 0  -  2
#xform.isInitialised()  False
#xform.destCRS()  <qgis._core.QgsCoordinateReferenceSystem object at 0x8beb320>

This electronic message, as well as any transmitted files included in the electronic message, may contain privileged or confidential information and is intended solely for the use of the individual(s) or entity to which it is addressed. If you have received this electronic message in error please notify the sender immediately and delete the electronic message. Any unauthorized copying, disclosure or distribution of the electronic message is strictly forbidden. NAV CANADA accepts no liability for any damage caused by any virus and/or other malicious code transmitted by this electronic communication.

Le présent message électronique et tout fichier qui peut y être joint peuvent contenir des renseignements privilégiés ou confidentiels destinés à l’usage exclusif des personnes ou des organismes à qui ils s’adressent. Si vous avez reçu ce message électronique par erreur, veuillez en informer l’expéditeur immédiatement et supprimez le. Toute reproduction, divulgation ou distribution du présent message électronique est strictement interdite. NAV CANADA n’assume aucune responsabilité en cas de dommage causé par tout virus ou autre programme malveillant transmis par ce message électronique.


More information about the Qgis-user mailing list