is there any math formula for transforming from EPSG:4326 to EPSG:3857 ? i want to implement it in php code


Projection EPSG:3857 uses the method EPSG:1024 for Forward and Reverse calculations.

The method is fully documented at Geomatics Guidance Note No 7, part 2

There's an mathematical example at page 40 where you can use to cross-reference your code.

  • 1
    the given link in the answer is broken – gansub Oct 26 '17 at 10:41

I got a C# code for using in unity engine.

Here the code below :

public static double[] latLonToMeters(double lat, double lon)
    //Debug.Log(Mathd.Tan((90d + lat) * Mathd.PI / 720));
    //Debug.Log(Mathd.Tan((90d + lat) * Mathd.PI / 360d));
    double[] meters = new double[2];
    meters[0] = lat * originShift / 180d;
    meters[1] = Mathd.Log(Mathd.Tan((90d+lon) * Mathd.PI / 360d)) / (Mathd.PI / 180d);
    //meters[1] = Mathd.Log(5) / (Mathd.PI / 180d);
    meters[1] = meters[1] * originShift / 180d;
    return meters;

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.