GeoTiff Conversion – Convert GeoTiff to 16 Bit TIFF, PNG, or BMP for Heightmaps

gdalgeotiff-tiffqgisraster

I have a GeoTiff that acquired through processing Mars Hirise stereo images with ISIS3 and ASP. I want to convert it to a 16bit greyscale tiff, png or bmp file to use as a heightmap in a game engine, unreal engine 4. I tried converting it with gdal_translalte, first to 16 bit .raw but turns out photoshop can't open it in 16 bit only in 8bit, I get a message saying that the size is to big for the file in 16 bit, something that seems to have to do with the file size in byte, the two channels and the image size I try to import. Then I tried converting it to tiff and png, also with gdal_translate but both images are just black when I open them. I tried opening my GeoTiff with BelnderGIS but it is just a flat plane. I opened the Geotiff in QGIS and then I see that it does have information and is not just flat and black. I made a smaller cropped version of the DEM and opened it in MicroDEM which works but when I try to open the original file it says that it is too big.

Does anybody know how I could do this, with gdal, qgis or something else? I'm very new to using both gdal and and qgis, I just followed examples from others but there might be a way to do it so it works for me in the end.

Best Answer

I think the problem could be with the range of values in your original image. You can use the -scale parameter in gdal_translate to get images within the range of an 8 bit image.

For example

gdal_translate -of PNG -ot Byte -scale in_tiff.tif out_png_scaled.png

This will automatically set the input minimum and maximum values used to scale, if these don't work you can specify a minimum and maximum value after -scale.

If you need to make the image smaller you can also resize with gdal_translate using -outsize. For example, -outsize 50% 50% will resize to 50 % of the original.