I have a set of DEM tiles (TIFF format) retrieved from https://cteco.uconn.edu/data/download/flight2016/index.htm which I would like to convert to 16-bit PNG format so that I can use them as heightmaps in Unreal Engine 5.

Referencing this question and this question, I downloaded QGIS3 and used the Raster → Conversion → Translate menu to attempt conversion to UInt16 with the following command:

gdal_translate -ot UInt16 -of PNG H:/Programming/Heightmaps/840630nw_x0_y0.tif H:/Programming/Heightmaps/output.png

The resulting image, however, is completely black and trying to import it into UE5 gives me a completely flat landscape so it's not just the preview unable to render. When I inspect its properties using the Windows context menu, I see that the pixel depth is 64 bits as opposed to the 16 I would expect. If I try any of the other output data types such as Byte, I get a depth of 8 bits which results in a blocky heightmap.

I don't work in the GIS space and have never done any image manipulation so talk of bands and depth goes a bit over my head. I am hoping someone can explain what might be going wrong and how I can fix it.

EDIT: Results from commands suggested by @user2856 here.

  • 1
    Works for me. Make sure you download the file labelled "DEM", not "TIFF", e.g. cteco.uconn.edu/download/DEM/2016/tiles/790755_nw.zip. The zip contains a GeoTIFF, but it's the actual elevation data, not just an image. I then ran gdal_translate -ot UInt16 -of PNG 790755_nw.tif 790755_nw.png and got a single band 16bit PNG with correct elevation values (checked in QGIS). If this is not working for you, edit your question and add the outputs of gdalinfo -stats 840630nw_x0_y0.tif and the same for the output png.
    – user2856
    Jul 16, 2021 at 0:49
  • Forgot to mention... my output png looked completely black when I accidentally opened it in the default Windows image viewer, but that because that software was designed to handle pictures, i.e 3 or 4 channel (band) RGB or RGB+Alpha 8bit per channel files. I notice Windows reports your output as 64bit, which makes me think you may have downloaded the "TIFF" image (your output png would have 4 channels, each 16bit == 64bit). If your input tif is a few mb file size (790755_nw.zip DEM is 3.7mb), you've got the elevation, if it's hundreds (790755_nw.zip TIFF is >300mb) you got the aerial imagery.
    – user2856
    Jul 16, 2021 at 2:49
  • Okay; interesting. I re-downloaded all the tiles making sure to get the DEM versions. I thought maybe that solved my problem since the first one I converted came out properly as 16-bit. However the second is still producing a 64-bit result. I also get an error in QGIS with that one: Warning 1: for band 1, nodata value has been clamped to 0, the original value being out of range. I am updating the question with the results from the console commands.
    – Matt
    Jul 16, 2021 at 4:10
  • 1
    No your output PNG is 16 bit according to the gdalinfo output, the only difference I can see is the NoData value metadata. Try adding -a_nodata None in "Additional command-line parameters" - gdal_translate -ot UInt16 -of PNG -a_nodata None 840625_nw.tif 840625_nw.png
    – user2856
    Jul 16, 2021 at 4:58
  • Hmm it got rid of the error but Windows still shows that file as having 64-bit depth although I see from gdalinfo that it is indeed UInt16. I get the same flat plane when importing either result into UE5 though so it seems even the one that's "working" isn't actually working.
    – Matt
    Jul 16, 2021 at 5:15


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.