Gdal2Tiles getting tif with dtype = uint8 but want int16

المشرف العام

Administrator
طاقم الإدارة
I have a gdal2tiles code for getting tiff file. In my code I am getting true tiff format but it makes my dype uint8. I want int16 for dtype. how can I overcome it? I know I have to add gdal.GDT_Int16 somewhere but I don't know where... the relevant parts of the my code:

default_tileformat = 'png' tempdriver = gdal.GetDriverByName( 'MEM' ) tiledriver = gdal.GetDriverByName( default_tileformat ) ... def writetile( filename, data, dxsize, dysize, bands): """ Write raster 'data' (of the size 'dataxsize' x 'dataysize') read from 'dataset' into the tile 'filename' with size 'tilesize' pixels. Later this should be replaced by new from GDAL. """ # Create needed directories for output dirs, file = os.path.split(filename) if not os.path.isdir(dirs): os.makedirs(dirs) # GRR, PNG DRIVER DOESN'T HAVE CREATE() !!! # so we have to create temporary file in memmory... #TODO: Add transparency to files with one band only too (grayscale). if bands == 3 and tileformat == 'png': tmp = tempdriver.Create('', tilesize, tilesize, bands=4) alpha = tmp.GetRasterBand(4) alphaarray = (zeros((dysize, dxsize)) + 255).astype('l') alpha.WriteArray( alphaarray, 0, tilesize-dysize ) else: tmp = tempdriver.Create('', tilesize, tilesize, bands=bands) # (write data from the bottom left corner) tmp.WriteRaster( 0, tilesize-dysize, dxsize, dysize, data, band_list=range(1, bands+1)) # ... and then copy it into the final tile with given filename tiledriver.CreateCopy(filename, tmp, strict=0, options=gdal_driver_options) return 0 and another part:

# Load raster from read window. data = dataset.ReadRaster(rx, ry, rxsize, rysize, dxsize, dysize) # Write that raster to the tile. writetile( filename, data, dxsize, dysize, bands)

أكثر...
 
أعلى