[gdal-dev] [gdal2tiles.py] Crash if the asked tile level is from too high

Even Rouault even.rouault at spatialys.com
Thu Jan 26 06:05:55 PST 2017


On jeudi 26 janvier 2017 10:03:56 CET Grégory Bataille wrote:
> Hey all,
> 
> So if you try to launch gdal2tiles.py with an asked tile level that is from
> very high, so that the output should be a single tile where not a single
> pixel value of the original raster is displayed, gdal2tiles.py simply
> crashes (stack trace) when trying to write nothing in the output file

Python crash, right, not core crash, right ?

Here's what I get:

"""
('\tReadRaster Extent: ', (0, 0, 504, 454), (228, 24, 0, 0))
ERROR 5: Illegal values for buffer size
ERROR 5: Illegal values for buffer size
Traceback (most recent call last):
  File "gdal/swig/python/scripts/gdal2tiles.py", line 2452, in <module>
    main()
  File "gdal/swig/python/scripts/gdal2tiles.py", line 2449, in main
    gdal2tiles.process()
  File "gdal/swig/python/scripts/gdal2tiles.py", line 484, in process
    self.generate_base_tiles()
  File "gdal/swig/python/scripts/gdal2tiles.py", line 1318, in generate_base_tiles
    dsquery.WriteRaster(wx, wy, wxsize, wysize, data, 
band_list=list(range(1,self.dataBandsCount+1)))
  File "/home/even/gdal/trunk/gdal/swig/python/build/lib.linux-x86_64-2.7/osgeo/gdal.py", 
line 2038, in WriteRaster
    buf_pixel_space, buf_line_space, buf_band_space )
TypeError: not a string
"""


> 
> What would you prefer as the "fixed" behaviour?
> - some message is displayed on the stderr and then the script exits with a
> non-zero exit code
> - we generate a single empty (transparent tile) and complete successfully?

Empty tile would seem to be appropriate. Perhaps we could also emit a warning (in non quiet 
mode) indicating that this zoom level and downwards are empty ?

> 
> 
> To reproduce, you can do this on trunk (with z = 10 or smaller)
> 
> > python gdal/swig/python/scripts/gdal2tiles.py
> > autotest/pyscripts/data/test_bounds_close_to_tile_bounds_x.vrt
> > /tmp/out_small -z 10 -v
> 
> (note that starting at a lower level and generating higher level tiles by
> downsampling works and generates 1 empty tile --> maybe we should do the
> same

didn't you mean "starting at a higher level and generating lower level tiles by downsampling" 
instead ?

> 
> > python gdal/swig/python/scripts/gdal2tiles.py
> > autotest/pyscripts/data/test_bounds_close_to_tile_bounds_x.vrt
> > /tmp/out_small -z 10 -v

--> this is the same command as above.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170126/a0b5d76b/attachment.html>


More information about the gdal-dev mailing list