Skip to content

Instantly share code, notes, and snippets.

@dandye
Created May 15, 2012 15:11
Show Gist options
  • Save dandye/2702528 to your computer and use it in GitHub Desktop.
Save dandye/2702528 to your computer and use it in GitHub Desktop.
LatLonToTile
import gdal2tiles
for zoom in range(3):
west = -179.99
north = 89.99
print "---\nzoom %s" % zoom
gg = gdal2tiles.GlobalGeodetic()
sm = gdal2tiles.GlobalMercator()
tx,ty = gg.LatLonToTile(north, west, zoom)
print 'TMS tx,ty = %s, %s' % (str(tx),str(ty))
tx,ty = sm.GoogleTile(tx,ty,zoom)
print 'Google tx,ty = %s, %s' % (str(tx),str(ty))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment