Coordinate System – Converting WGS84 to ED50 (Non-UTM) Using C#

ccoordinate systemdotspatial

I'm trying to convert between WSG84 and ED50 (non-UTM) using C# and DotSpatial.Projections:

using DotSpatial.Projections;
using System;
using System.Linq;

namespace ConvertWGS84ToEd50
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] xy = { 44.59740000, 10.69170000 };
            double[] z = { 98 };

            Console.WriteLine($"Input  -> Lat:{xy[0]} Lon:{xy[1]}");

            var wgs84 = KnownCoordinateSystems.Geographic.World.WGS1984;
            var ed50 = KnownCoordinateSystems.Geographic.Europe.EuropeanDatum1950;

            Reproject.ReprojectPoints(xy, z, wgs84, ed50, 0, 1);

            Console.WriteLine($"Output -> Lat:{xy[0]} Lon:{xy[1]}");
            Console.WriteLine("Press any key to continue..");
            Console.ReadKey(true);
        }
    }
}

But it gives me the same output as the input. I'm expecting a small variation in the coordinates like (44.598342, 10.6927). Can someone please suggest me what I'm doing wrong?

Best Answer

With the help of the author, I fixed the above code as following:

  1. Coordinates were mixed: double[] xy = { 10.69170000, 44.59740000 };

  2. Destination projection I've used: ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +no_defs");

About point (2), I've asked on the Github page of the project why the constant is not working. You can follow the discussion here.