1

I am using dotspatial version 1.9 to reproject a shapefile form EPSG:2326 to EPSG:3857 and I am getting wrong results. For a single point x:835869.4538390070 y:815974.4885250400

the result is x:12709407.9774734 y:2545678.93085044 when using proj4 string (and completely different when I am using the ESRI String)

The correct outcome (according to epsg.io online transformation tool) should be: x: 12709681.01 y: 2545494.73

which is in accordance with what I get using PostGIS.

Any ideas why the dotspatial doesn't give me the correct result?

The code I am using is:

        Double x;
        Double y;
        x = 835869.4538390070;
        y = 815974.4885250400;

        String proj4_2326_str = "+proj=tmerc +lat_0=22.31213333333334 +lon_0=114.1785555555556 +k=1 +x_0=836694.05 +y_0=819069.8 +ellps=intl +towgs84=-162.619,-276.959,-161.764,0.067753,-2.24365,-1.15883,-1.09425 +units=m +no_defs";
        String proj4_3857_str = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs";
        ProjectionInfo proj2326 = ProjectionInfo.FromProj4String(proj4_2326_str);
        ProjectionInfo proj3857 = ProjectionInfo.FromProj4String(proj4_3857_str);

        double[] xy = new double[2] { x, y };
        double[] z = new double[1] { 0 };

        Reproject.ReprojectPoints(xy, z, proj2326, proj3857, 0, 1);

        textBox7.Text = xy[0].ToString();
        textBox8.Text = xy[1].ToString();
  • Hi, did you ever solve this? I seem to be having a similar issue. – Ian Newson Aug 19 at 17:48
  • 1
    Not really. The closest I came to a solution is to use EPSG:4326 as an intermediate step. I am converting from 2326 to 4326 and then from 4326 to 3857. It seems I get the proper results this way – eblOnSO Aug 28 at 9:50

Your Answer

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

Browse other questions tagged or ask your own question.