[gdal-dev] gdal2tiles for 16bit data

Jan Tosovsky j.tosovsky at email.cz
Sat Sep 20 08:02:12 PDT 2014


On 2014-09-20 David Strip wrote:
> > On 9/20/2014 6:20 AM, Jan Tosovsky wrote:
> >
> > I am trying to produce GeoTiff tiles from my SRTM based GeoTiff:
> > gdal2tiles.py -z 6-7 warped.tif D:\tiles-gdal
> >
> > The problem is that the final data is somehow converted from
> > 16bit into 8bit so useless for intended further processing.
> > ...
>
> A few lines before the ones you quoted from the script dstile is set to
> a raster in memory:
> 
> dstile = self.mem_drv.Create('', self.tilesize, self.tilesize,
> tilebands)
> 
> This memory dataset driver defaults to a datatype of byte. You need to
> override this to the datatype of your choice. I'm not familiar enough
> with the Python interface to be able to tell you how to do that in
> Python, though.
> 

A good catch, thanks. 

Adding an extra parameter seems to be fixing this:
dstile = self.mem_drv.Create('', self.tilesize, self.tilesize, tilebands,
gdal.GDT_UInt16)
(applied to all 'mem_drv.Create' occurrences)

But the final tif has most likely incorrect metadata as its reading via
jai-imageio fails ArrayIndexOutOfBoundsException: 256

(Despite the Ok result when reading the tiling source image using the same
method)

Any idea?

Thanks, Jan



More information about the gdal-dev mailing list