Im using to gdal_translate
to create tiled DEM, tif(float32) -> PNG (UInt16)
.
All the images trun out black.
When I change UInt
to byte
- everything work as expected.
What am I doing wrong?
import os, gdal
in_path = 'C:\\xxx\\'
input_filename = 'input.tif'
out_path = 'C:\\xxx\\'
output_filename = 'tile_x'
tile_size_x = 8129
tile_size_y = 8129
ds = gdal.Open(in_path + input_filename)
band = ds.GetRasterBand(1)
xsize = band.XSize
ysize = band.YSize
xCnt, yCnt = -1, -1
for i in range(0, xsize, tile_size_x):
xCnt = xCnt+1
yCnt = -1
for j in range(0, ysize, tile_size_y):
yCnt = yCnt+1
com_string = "gdal_translate -of PNG -ot UInt16 -srcwin " + str(i)+ ", " + str(j) + ", " + str(tile_size_x) + ", " + str(tile_size_y) + " " + str(in_path) + str(input_filename) + " " + str(out_path) + str(output_filename) + str(xCnt) + "_y" + str(yCnt) + ".png"
os.system(com_string)
gdalinfo -hist
. Is the histogram biased to the low end? If your viewer is utilizing the full UInt16 scale but all the data is near the black end the image appear black. What viewer do you use? Can it apply Min-Max stretch or some other contrast enhancement? – user30184 Jun 10 '18 at 12:02