Select to view content in your preferred language

Wrong values for Geographic Transformation

913
4
Jump to solution
07-08-2013 07:10 AM
AlexanderHaberl
Deactivated User
Hi!
I want to transform a number of points from MGI_Austria_GK_East to GCS_WGS_1984. When I do that in ArcMap (with the "Project" tool) everything works perfectly. Now I tried to do the same programmatically in C#, but the results are totally wrong. Please help and tell me, what I am doing wrong! Thanks a lot!
Here's my code:

private void btnStartTransform_Click(object sender, EventArgs e)         {             Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");             System.Object obj = Activator.CreateInstance(factoryType);             ISpatialReferenceFactory2 spatialReferenceFactory2 = obj as ISpatialReferenceFactory2;              IGeoTransformation geoTransformation = spatialReferenceFactory2.CreateGeoTransformation((int)esriSRGeoTransformation3Type.esriSRGeoTransformation_MGI_To_WGS_1984_3) as IGeoTransformation;              //In Point (MGI_Austria_GK_East): -50545.72, 362614.3             //Out Point should be: (WGS1984 Longitude/Latitude in decimal degree): 15.649504022257, 48.3997325959545              double[] inPoints = new double[2];             double[] outPoints = new double[2];              inPoints[0] = -50545.72d;             inPoints[1] = 362614.3d;              geoTransformation.TransformPointsFF(esriTransformDirection.esriTransformForward, 1, ref inPoints[0], ref outPoints[0]);              //Values are: -6.2468353377012207, 89.99439100965067 ????             System.Windows.Forms.MessageBox.Show("Longitude:" + outPoints[0] + ", Latitude: " + outPoints[1]);         }
0 Kudos
1 Solution

Accepted Solutions
MelitaKennedy
Esri Notable Contributor
Oh, stupid me! I didn't read your post closely enough.

Is there a reason why you aren't using ProjectEx rather than TransformFF? I think it's treating the input coordinates are decimal degrees rather than unproject them, then apply the geotransformation.

Melita

View solution in original post

0 Kudos
4 Replies
MelitaKennedy
Esri Notable Contributor
Change the order of the input x and y values. In Esri-land, x = easting, y = northing and the order is x,y. If coordinates are in a geographic coordinate reference system, they're usually given in longitude,latitude order.

Melita
0 Kudos
AlexanderHaberl
Deactivated User
Thanks for your reply, I already tried to swap the coordinates, that gives me

[0] = 25.035063914873405
[1] = -89.994743157825781

in my outpoints array...

Here are the values I should get again:

            //In Point (MGI_Austria_GK_East): -50545.72, 362614.3
            //Out Point should be: (WGS1984 Longitude/Latitude in decimal degree): 15.649504022257, 48.3997325959545
0 Kudos
MelitaKennedy
Esri Notable Contributor
Oh, stupid me! I didn't read your post closely enough.

Is there a reason why you aren't using ProjectEx rather than TransformFF? I think it's treating the input coordinates are decimal degrees rather than unproject them, then apply the geotransformation.

Melita
0 Kudos
AlexanderHaberl
Deactivated User
Thanks a lot, it works with ProjextEx() method.
0 Kudos