Search code examples
mapsmercator

Map scale factor when converting from Mercator to Equirectangular


Lets say I have a map in Mercator projection, and I know top and bottom latitudes:

topLatitude = 80; bottomLatitude = -55;

I also know width and height of a map:

width = 800; height = 500;

I want to rescale the map to Equirectangular projection, keeping the same width.

How can I calculate new height of a map?


Solution

  • I came up with a solution.

    This is formula to calculate x and y of Mercator projected map:

    Here is function for y:

    function degreesToRadians(degrees){
        return degrees / 180 * Math.PI;
    }
    
    function mercatorLatitudeToY(latitude){
        return Math.log(Math.tan(Math.PI / 4 + degreesToRadians(latitude) / 2));
    }
    

    When R=1 the result you get is radians. So I calculate y for top and bottom latitudes.

    Next, I calculate the same radians if the projection is Equirectangular - I simply need to convert top and bottom latitude to radians. And last thing - I just need to find aspect ratio of differences:

    var scale =  (mercatorLatitudeToY(topLatitude) - mercatorLatitudeToY(bottomLatitude))/ (degreesToRadians(topLatitude) - degreesToRadians(bottomLatitude));
    

    For map without Antarctica, aspect ratio is ~1.5