Mercator Projection: Converting Latitude/Longitude to Mercator Projections
The Mercator projection is a map projection that conformal and equidistant along particular lines. It preserves the shape but not the area and is widely used for navigation charts.
Converting Latitude/Longitude to Mercator Projections
To convert a latitude/longitude point to a Mercator projection, we use the following formulas:
E = FE + R (λ – λₒ) N = FN + R ln[tan(π/4 + φ/2)]
where:
For the Mercator Sphere, FE and FN are 0, simplifying the formula to:
E = R * (λ – λₒ) N = R * ln[tan(π/4 + φ/2)]
Code Example
In pseudo code, we convert latitude and longitude to Mercator projections as follows:
latitude = 41.145556; // (φ) longitude = -73.995; // (λ) mapWidth = 200; mapHeight = 100; // get x value x = (longitude+180)*(mapWidth/360) // convert from degrees to radians latRad = latitude*PI/180 // get y value mercN = ln(tan((PI/4)+(latRad/2))); y = (mapHeight/2)-(mapWidth*mercN/(2*PI));
By applying these formulas and converting from radians to degrees as necessary, we can accurately convert latitude/longitude points to Mercator projections. This knowledge is essential for displaying data on Mercator-projected maps.
The above is the detailed content of How do you convert latitude and longitude to Mercator projections?. For more information, please follow other related articles on the PHP Chinese website!