Results 1 to 7 of 7

Thread: Making a Mercator Projection from Scratch

  1. #1
    Community Leader Guild Sponsor Gidde's Avatar
    Join Date
    May 2009
    Location
    Michigan, USA
    Posts
    3,673

    Tutorial Making a Mercator Projection from Scratch

    Ok, as a forum noob, I'm not sure if this is a tutorial per se, but I just created this for my new map and I thought I'd share, because it took me hours of research to figure out how to do it.

    What I was trying to do was figure out where the latitude lines should be in a Mercator map of a world that doesn't exist (yet). I chose Mercator for the same apparent reason that Google did -- it's zoomable as-is, without having to reproject a continent (or piece of one) before you do a blow-up version of it.

    So, if you pick a circumference for your world, and a base scale (scale at equator), and a cut-off latitude (70-85, usually, depending on how much distortion you want to put up with), this OpenOffice spreadsheet (the zip contains both .ods and .xls versions in case you have Excel) will calculate where to put latitude lines, how big (in pixels) your map should be total, and what the scale is at each latitude for your zoomed-in maps.

    I hope this helps anyone who's ambitious (or crazy) enough to want to make a whole world map.

  2. #2
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,288
    Blog Entries
    8

    Post

    Hey Gidde - welcome to the guild. Just looking at your spreadsheet and it seems pretty good. I'll take your word for it that the math is right. Not sure why log's are in there but I guess they must be. I noticed too that you have mi as units. I think thayre nautical miles, it wasn't clear so thought id mention it.

    Well done. A new tutorial gets rep from me.

  3. #3
    Community Leader Guild Sponsor Gidde's Avatar
    Join Date
    May 2009
    Location
    Michigan, USA
    Posts
    3,673

    Post

    Woot, thanks for the rep!

    Miles/Nautical miles/Kilometers is actually irrelevant as far as the spreadsheet goes ... the unit cancels out in the math when you go from whatever it is to pixels, since you're specifying both the actual size and the scale.

    I probably should have referenced where I got the math .... this is the site I found that finally made it click.

    http://www.math.upenn.edu/~ugrad/mac...ator/mcalc.htm

    Everywhere else, I could find the projection formula, but none of the sites actually explained how to take the projection formula and turn it into miles/inches/pixels/etc.

  4. #4
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,288
    Blog Entries
    8

    Post

    Well I think I am right in saying that the Mercator is where the world is stretched so that the circumferences at every latitude are made to fit the width of the page.

    If that's correct then the circumference at latitude degree y is equatorial circumference multiplied by cos y. If page width in pixels is px then scale is px / (equ * cos(y)) or inverted if you want pixels per mile or whatever units your in.

    But anyway, I think its not too complicated or else I don't understand the real issue with it. Perhaps they use a non linear scale or a non angular scale for the latitude to py mapping...

  5. #5
    Community Leader Guild Sponsor Gidde's Avatar
    Join Date
    May 2009
    Location
    Michigan, USA
    Posts
    3,673

    Post

    Yep, correct in general terms. The reason the y values are logarithmic is that since the scale is continually changing, y is actually the integral of the scale equation. So the scale equation ends up being something like ...

    (px/unit of latitude)/equ*cos(lat)

    ... and the integral of 1/cos = ln(|sec+tan|), which is the projection formula (minus the units and scale).

    Yuck. Never thought I'd actually come up with a use for integral calculus ...

  6. #6
    Community Leader Guild Sponsor Gidde's Avatar
    Join Date
    May 2009
    Location
    Michigan, USA
    Posts
    3,673

    Post

    This is the current world map I'm working on, converted (roughly) from the equirectangular produced by PlanetGen to the mercator I wanted to work from, using the calcs in the above worksheets.

    Sorry for the jarring black and white of land vs sea ... the conversion is a LOT of work, so I'm using the working map rather than a prettier one

  7. #7

    Default

    hi, i can't find your spreadsheet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •