Monday, 11 July 2011

Mercator projection to convert longitude and latitude


Online KML viewer:
http://display-kml.appspot.com/

Useful links:
http://code.google.com/intl/fr/apis/kml/documentation/kmlreference.html
http://mathworld.wolfram.com/MapProjection.html

Thanks the author of online kml2svg tool (http://kml2svg.free.fr/index.php), Franklin, the conversion between KML and SVG is:

need to convert a earth coordinate (lattitude/longitude) into a screen position (x/y).

Mercator projection:
    // λ  = longitude
    // φ  = latitude
    φ = deg2rad (φ );
    λ = deg2rad (λ );
    x = λ;
    y = -log ( tan (pi() / 4 + φ / 2) , 2.718282 );


Some formulas are much more complex, some needs input references grids, etc. Mercator and Lambert projections are relatively simpler.

No comments:

Post a Comment