Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am working on calculating tile bounds lat lon from x,y,z tile coordinate. i have looked gdal2tiles code structure and i have found this good function:

def TileLatLonBounds( tx, ty, zoom ):
"Returns bounds of the given tile in latutude/longitude using WGS84 datum"

bounds = TileBounds(tx, ty, zoom)
minLat, minLon = MetersToLatLon(bounds[0], bounds[1])
maxLat, maxLon = MetersToLatLon(bounds[2], bounds[3])

with this code and its dependies i am getting result of this for tms scheme:

1.TileLatLonBounds(0, 3, 2) # 66.51326044311185, -180.0, 85.0511287798066, -90.0
2.TileLatLonBounds(3, 0, 2) # -85.05112877980659, 89.99999999999999, -66.51326044311185, 180.0

but i know world extent is for upper left -180 90, for lower right is 180 -90. so for first function (minLat, minLon, maxLat, maxLon) maxLat must be 90 instead of 85.0511287798066 and for second function minlat must be -90 instead of -85.05112877980659.

if i want use gdal translate function for rectifying for an image which contains world extent, then web tiling it, and using with openlayers or anything like this i think there will be problem with click into place of its....

and when opening -180 90 180 -90 tif and -180 85.05112877980659 180 -85.05112877980659 tif with global mapper you can see the diffrence of coordinate...

ok. what is your opinion for fixing this problem? or is it not a problem for tiling with gdal2tiles

share|improve this question
when i remove this "lat = 180 / math.pi * (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0)" from MetersToLatLon( mx, my ) function, such as result may improved.. what is your opinion – Aragon Feb 10 '12 at 17:30
up vote 2 down vote accepted

Read up on Web Mercator. Tiles go to -Infinity at -90, not 0, and that's why the gdal2tiles code works the way it does.

share|improve this answer
ok. now i will commenting above code and i think this will take me the right way... – Aragon Feb 11 '12 at 15:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.