Heightmap Conversion with GDAL

Category

GIS

Last modified

6 July 2018
16 bit Mt Ruapehu

Mt Ruapehu modelled from a 16 bit grayscale heightmap

8 bit Mt Ruapehu

Mt Ruapehu modelled from an 8 bit grayscale heightmap.

Introduction

GDAL (Geospatial Data Abstraction Library) can convert heightmaps into a format usable by 3d modelling software. Unlike QGIS it is not limited to 256 shades of gray (8 bit grayscale). Compare the two images above and note how much better the first model is because it was made using a heightmap with 65535 shades of grey.

Method

Navigate to the directory containing your source file.

Obtain the MIN MAX heights by typing:-

gdalinfo -mm "source.tiff"

Then use those values to replace MIN MAX below:-

gdal_translate -of PNG -ot UInt16 -scale MIN MAX 0 65535 "source" "destination.png"

Source

How can I create a 16bit PNG heightmap in QGIS?

Discussion

Kim Holder
This tool looks like a godsend for me, but it's giving me an error. I'm trying to downsample and image that's 32 bit to 16 bit - as near as I can tell, anyways. GDal gives me a computed Min/Max = -3184.302. 774.906. When I rounded those numbers and fed that in for the translate operation, it didn't like the negative number. So I put the negative number as 0 and added that amount to the Max number. It says ERROR 6: Too many command options '0'. ImageMagick tells me the image is Depth: 32/16 bit, and the Channel depth: gray: 16-bit. Can you help me out with this? Much appreciated if you can.
KeePing
You probably already found the answer... But for your case, the command should look like: gdal_translate -of PNG -ot UInt16 -scale -3184.302 774.906 0 65535 <your input file.tif> <your output file.png>
John Flower

Thank you, KeePing

Freddy Arteaga
I DO NOT HAVE GIS SOFTWARE. I HAVE 3 TIFF FILES THAT I NEED TO USE. HOW DO I CONVEWRT A TIFF FILE THAT IS BLACK INTO A USEABLE TOPO FILE?
John Flower

Hi Freddy,

QGIS is free and can help you to create such a file.

Add a remark

Your email will be private. It is used to notify you of replies to your remark.

Plain text

  • No HTML tags allowed.