Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hello, I'm trying to show a map on Android. I'm using two map providers and am having trouble when converting geo point(lat/lon) to point in my viewport(x/y in pixels).

1) the first map provider used wgs84 -> EPSG:3395 projection
2) the second map provider used EPSG:4326(wgs84) -> EPSG:3395 projection

In the first case I can place any lat/lon correctly.
In the second case I have a discrepancy. I'm not sure about 2 km or more.

Why do I get this discrepancy if the projection of the providers is the same?

Please help me understand this.

UPD: This is the java code

        d = lon * Math.PI / 180, 
        m = lat * Math.PI / 180,
        l = 6378137,
        k = 0.0818191908426,// somebody explain what this constant means?
        f = k * Math.sin(m);

        h = Math.tan(Math.PI / 4 + m / 2),
        j = Math.pow(Math.tan(Math.PI / 4 + Math.asin(f) / 2), k), 
        i = h / j;

        double[] res = {l * d, l * Math.log(i)};
        return res;

This code works for wgs84 -> EPSG:3395. I know thsi is the wrong approach but I just changed constant k = 0.0818191908426 to my constant and it should work for some geographic region, but I think on the pole it will be wrong.

share|improve this question
Updated my answer. Now have a suggestion for a Java library. – R.K. Sep 26 '12 at 10:21
up vote 0 down vote accepted

The two are not the same.


WGS84 Bounds: -180.0000, -90.0000, 180.0000, 90.0000
Projected Bounds: -180.0000, -90.0000, 180.0000, 90.0000
Scope: Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.
Last Revised: 2007-08-27
Area: World


WGS84 Bounds: -180.0000, -80.0000, 180.0000, 84.0000
Projected Bounds: -20037508.3428, -15496570.7397, 20037508.3428, 18764656.2314
Scope: Very small scale mapping.
Last Revised: 2006-06-02
Area: World - between 80°S and 84°N

One is projected while the other is a geographic projection.

You're better off using existing map projection libraries instead of writing your own. You might want to try out the Java Map Projection Library which is a partial port of the proj4 library mentioned by BradHards.

share|improve this answer
I can convert wgs84 -> EPSG:3395 see update how i do that. How i can convert EPSG:4326 -> EPSG:3395? – Mrusful Sep 26 '12 at 9:30
Perhaps you would be better off using a projection tool, like proj4 ( is a java version, but I haven't used it - I'd suggest as a safe alternative) – BradHards Sep 26 '12 at 9:58
I tried to learn how it doing in library as OpenLayers. This library used proj4j. I tried to learn how it doing in proj4j but not to end. Ok looks like I have to take it completely to my android app ( thanks – Mrusful Sep 26 '12 at 11:09

The value k = 0.0818191908426 is referred to as the First Eccentricity of the Earth.

This value is used in equations to convert between coordinate system values of position, such as lat-long-alt to ECEF coordinates.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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