2

I've used Proj.Net in my c# application to convert from UTM 39N to WGS 84 as below:

private const string wkt32639 ="PROJCS[\"WGS 84 / UTM zone 39N\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",51],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"32639\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]";
        public static void ProjectLatLngToXY(double lat, double lng, out double[] xy)
        {
            var gcs_WGS84 = GeographicCoordinateSystem.WGS84;

            var cf = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
            var f = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            var sys32639 = cf.CreateFromWkt(wkt32639);

            var transformTo3857 = f.CreateFromCoordinateSystems(sys32639, gcs_WGS84);
            double[] fromPoint = {lat, lng};
            xy = transformTo3857.MathTransform.Transform(fromPoint);
        }

But it gives me the wrong coordinate: WGS84(30.8463279037339, 53.5421539663397) --> UTM( 46.511532454882378, 0.00048291699191924472).

What is the problem?

2

I think you have confused which direction you are going in:

Going from 32639 to 4326 (Metres to Degrees):

$ gdaltransform -s_srs epsg:32639 -t_srs epsg:4326
30.8463279037339, 53.5421539663397
46.5115324673363 0.000482916992353892 0

Going from 4326 to 32639 (Degrees to Metres):

$ gdaltransform -t_srs epsg:32639 -s_srs epsg:4326
30.8463279037339, 53.5421539663397
-826917.234636638 6123647.25526846 0
  • Thanks, but I think you should switch lat and long. I checked in PostGIS and spatialreference.org, so the correct coordinate is: 743115.83801353374, 3415337.9391538287 – nasser tahani Jul 10 '17 at 13:26
  • I just copied your example – Ian Turton Jul 10 '17 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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