[GIS] Coordinate transformation/reprojection using DotSpatial

ccoordinate systemdotspatial

The following piece of code worked with an older version of DotSpatial.

public static Geometry Project_EPSG25832_To_EPSG3857(byte[] wkb, int SRID)
    {
        NetTopologySuite.IO.WKBReader reader = new NetTopologySuite.IO.WKBReader();
        Geometry geom = (Geometry)reader.Read(wkb);

        var epsg25832 = new DotSpatial.Projections.ProjectionInfo();
        var epsg3857 = new DotSpatial.Projections.ProjectionInfo();
        epsg25832.ParseEsriString(ESRI_EPSG_25832);
        epsg3857.ParseEsriString(ESRI_EPSG_3857);

        Geometry transformedGeom = (Geometry)DotSpatial.Projections.GeometryTransform.TransformGeometry(geom, epsg25832, epsg3857, NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory());

        return transformedGeom;
    }

I had to upgrade the DotSpatial suite to the latest version and now the above code breaks. It seems the "DotSpatial.Projections.GeometryTransform" class doesn't exist any more.

I can't seem to find anything similar in the new version of DotSpatial except for this method

Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1);

…but it takes an array of points…

Anybody know of a nice and easy way of coming from a WKB to an array of points, or maybe there is another library that is easier to use in .NET/C#??

Best Answer

Where is the problem, simply use this:

double lat = 8.654;
double lon = 38.123;

double[] xy = new double[2] { lat, lon };
double[] z = new double[1] { 1234.5 };

Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1);

Console.WriteLine(String.Foramt("New Lat/Lon = {0}/{1}", xy[0], xy[1]));
Related Question