Opened 9 years ago
Closed 8 years ago
#6057 closed defect (fixed)
gdal2tiles.py patch for managing empty tiles
Reported by: | Kurt Schwehr | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: |
Description
Another Google engineer, Hideto Kazawa, found that gdal2tiles.py crashes for empty tiles.
swig/python/scripts/gdal2tiles.py -z 7-21 debug.tif tmp Generating Base Tiles: ERROR 5: Illegal values for buffer size ERROR 5: Illegal values for buffer size Traceback (most recent call last): File "./swig/python/scripts/gdal2tiles.py", line 2272, in <module> gdal2tiles.process() File "./swig/python/scripts/gdal2tiles.py", line 481, in process self.generate_base_tiles() File "./swig/python/scripts/gdal2tiles.py", line 1282, in generate_base_tiles dsquery.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1,self.dataBandsCount+1))) File "/home/schwehr/src/gdal/inst/lib/python2.7/site-packages/GDAL-2.1.0-py2.7-linux-x86_64.egg/osgeo/gdal.py", line 856, in WriteRaster buf_pixel_space, buf_line_space, buf_band_space ) TypeError: not a string
He proposes this patch. It looks okay to me, but I could use a double check. Does this look reasonable? If there aren't any concerns, I'll go ahead and apply it to trunk.
-
swig/python/scripts/gdal2tiles.py
svn diff swig/python/scripts/gdal2tiles.py
1257 1257 if self.options.verbose: 1258 1258 print("\tReadRaster Extent: ", (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) 1259 1259 1260 if wxsize == 0 or wysize == 0: 1261 continue 1262 1260 1263 # Query is in 'nearest neighbour' but can be bigger in then the tilesize 1261 1264 # We scale down the query to the tilesize by supplied algorithm. 1262 1265 … … 1364 1367 for x in range(2*tx,2*tx+2): 1365 1368 minx, miny, maxx, maxy = self.tminmax[tz+1] 1366 1369 if x >= minx and x <= maxx and y >= miny and y <= maxy: 1367 dsquerytile = gdal.Open( os.path.join( self.output, str(tz+1), str(x), "%s.%s" % (y, self.tileext)), gdal.GA_ReadOnly) 1370 tilefile = os.path.join(self.output, str(tz+1), str(x), "%s.%s" % (y, self.tileext)) 1371 if not os.path.exists(tilefile): 1372 continue 1373 dsquerytile = gdal.Open(tilefile , gdal.GA_ReadOnly) 1374 if dsquerytile is None: 1375 continue 1368 1376 if (ty==0 and y==1) or (ty!=0 and (y % (2*ty)) != 0): 1369 1377 tileposy = 0 1370 1378 else:
Attachments (1)
Change History (6)
by , 9 years ago
comment:2 by , 9 years ago
Replying to jratike80:
Yes, same patch as https://trac.osgeo.org/gdal/attachment/ticket/5005/gdal2tiles.patch #3596 is about empty/transparent content in tiles, whereas this one is about 0xX ou Xx0 tiles.
Looks good to me.
What would be most appreciated is a autotest/pyscripts/test_gdal2tiles.py script since we have none currently.
File that crashes gdal2tiles.py -z 7-21 debug.tif tmp