Converting tile y-coordinate to latitude

Hello all… my first post on here.

I’m trying to convert osm map tile coordinates (which range from 0 to n-1, where n doubles in size with each zoom level) to latitude and longitude co-ords.

So for zoom level 8, for example, the osm map is 256 tiles by 256 tiles. I can convert the x tile coordinate to a longitude easily by just dividing the x tile coord by 256, and then multiplying by 360 degrees. (And then subtracting from 90 degrees to recentre it around Greenwich of course)

But, I can’t work out the same calculation for latitude, as latitude isn’t linear. The only clue I can find in the Wiki is that it varies with the cosine of the angle - but if I highlight latitude 60 degrees north on the map, this doesn’t appear halfway between the equator and the top of the map, despite ‘cos (60 degrees)’ being equal to 0.5

So I’m kinda stuck… any idea what the formula to use is? I’ve tried reading descriptions of the projection osm is using, but it seems to be far more info than I can take in, or comprehend easily. A formula would be great though.

Thanks! :smiley:

Ah, never mind, found:

http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames

There are so many information sources on OSM it’s hard to work out where to get all your info from! Maybe a good problem to have though…