[Qgis-user] Issues with QgsCoordinateTransform - SOLVED

Tudorache, Marian Marian.Tudorache at navcanada.ca
Wed Sep 9 12:39:38 PDT 2015


I think I figured out.
First mistake: replace datum with ellps so the InternalCrsIdfor=100006 is: +proj=longlat +ellps=GRS80 +no_defs
Second Mistake:
Longitude that I use is 114 25 15.88 W'. Wrong. The longitude cannot be greater than 90 degree.
I changed the  longitude in range and it did work.

Any tip will be welcome.

Thanks,
Marian

-----Original Message-----
From: Tudorache, Marian
Sent: September-09-15 2:44 PM
To: 'qgis-user at lists.osgeo.org'
Subject: RE: Issues with QgsCoordinateTransform

Sorry the copy paste did not work well so I put the script uncleaned.
Here is the script again. The issue is the same: transformation from la/long to X / Y does not work.


 ######################################################
import processing, sys, os, math, LatLon, pyproj from PyQt4 import QtCore crsScr  = QgsCoordinateReferenceSystem(100006, QgsCoordinateReferenceSystem.InternalCrsId)
crsDest = QgsCoordinateReferenceSystem(100000, QgsCoordinateReferenceSystem.InternalCrsId)
xform = QgsCoordinateTransform(crsScr, crsDest)

coord_start = '53 30 21.88 N, 114 25 15.88 W'
coord_end = '54 40 21.88 N, 115 30 15.88 W'
start_Point = coord_start.split(',')
end_Point = coord_end.split(',')
start_Line = LatLon.string2latlon(str(start_Point[0]).strip(), str(start_Point[1]).strip(), 'd% %m% %S% %H') end_Line = LatLon.string2latlon(str(end_Point[0]).strip(), str(end_Point[1]).strip(), 'd% %m% %S% %H') print "QgsPoint = ",QgsPoint(float(start_Line.to_string()[0]), float(start_Line.to_string()[1]))

line_start = QgsPoint(float(start_Line.to_string()[0]), float(start_Line.to_string()[1])) line_end = QgsPoint(float(end_Line.to_string()[0]), float(end_Line.to_string()[1]))

pointGeomStart = QgsGeometry.fromPoint(line_start) pointGeomEnd = QgsGeometry.fromPoint(line_end)

print "Geometry points Start = {0}, End = {1}".format(pointGeomStart.asPoint(), pointGeomEnd.asPoint())

print "QgsCoordinateTransform.ReverseTransform = ",xform.transform(pointGeomStart.asPoint(), QgsCoordinateTransform.ReverseTransform)
print "QgsCoordinateTransform.ForwardTransform = ",xform.transform(pointGeomStart.asPoint(), QgsCoordinateTransform.ForwardTransform)
#####################################################################################################

The InternalCrsIdfor=100006 is: +proj=longlat +datum=GRS80 +no_defs The InternalCrsIdfor=100000 is: +proj=sterea +lat_0=53.5 +lon_0=-76.0 +k=1 +x_0=0 +y_0=0 +a=6381816.160744 +b=6381816.160744 +units=m +no_defs

I try to transform the coordinate '53 30 21.88 N, 114 25 15.88 W' and '54 40 21.88 N, 115 30 15.88 W' from 100006 to 100000

This is the output
QgsPoint =  (53.5061,-114.421)
Geometry points Start = (53.5061,-114.421),

End = (54.6727,-115.504)

QgsCoordinateTransform.ReverseTransform =  (53.5061,-114.421)

QgsCoordinateTransform.ForwardTransform =  (53.5061,-114.421)


Basically there is no diference between ReverseTransform and ForwardTransform. I am expecting to get X=-2549670.6 and Y=678.9 or (-2549670.6,678.9) when I am doing forward transformation.


Any idea what is wrong?

Thanks,
Marian

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