Skip to content

Instantly share code, notes, and snippets.

@wallclimber21
Created September 30, 2009 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallclimber21/197749 to your computer and use it in GitHub Desktop.
Save wallclimber21/197749 to your computer and use it in GitHub Desktop.
Patch to gdal2tiles.py so that it creates tiles that follow the Google tiles naming convention
@@ -1094,7 +1111,10 @@
for tx in range(tminx, tmaxx+1):
ti += 1
- tilefilename = os.path.join(self.output, str(tz), str(tx), "%s.%s" % (ty, self.tileext))
+
+ gtx, gty = self.mercator.GoogleTile(tx, ty, tz)
+ tilefilename = os.path.join(self.output, str(tz), str(gtx), "%s.%s" % (gty, self.tileext))
+
if self.options.verbose:
print ti,'/',tcount, tilefilename #, "( TileMapService: z / x / y )"
@@ -1234,7 +1254,9 @@
for tx in range(tminx, tmaxx+1):
ti += 1
- tilefilename = os.path.join( self.output, str(tz), str(tx), "%s.%s" % (ty, self.tileext) )
+
+ gtx, gty = self.mercator.GoogleTile(tx, ty, tz)
+ tilefilename = os.path.join( self.output, str(tz), str(gtx), "%s.%s" % (gty, self.tileext) )
if self.options.verbose:
print ti,'/',tcount, tilefilename #, "( TileMapService: z / x / y )"
@@ -1266,7 +1288,9 @@
for x in range(2*tx,2*tx+2):
minx, miny, maxx, maxy = self.tminmax[tz+1]
if x >= minx and x <= maxx and y >= miny and y <= maxy:
- dsquerytile = gdal.Open( os.path.join( self.output, str(tz+1), str(x), "%s.%s" % (y, self.tileext)), gdal.GA_ReadOnly)
+
+ gtx, gty = self.mercator.GoogleTile(x, y, tz+1)
+ dsquerytile = gdal.Open( os.path.join( self.output, str(tz+1), str(gtx), "%s.%s" % (gty, self.tileext)), gdal.GA_ReadOnly)
if (ty==0 and y==1) or (ty!=0 and (y % (2*ty)) != 0):
tileposy = 0
else:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment