Thread: Making a Mercator Projection from Scratch

1. 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. 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. 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.

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. 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. 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. 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