1

I've downloaded a TIFF taken by the Chang'e 2 orbiter. It's listed as a DEM file, and it came with 2 other files I didn't bother with because they are for GIS software - a .prj and a .tfw. When I open the TIF in GIMP it looks just black and white.

I vaguely recall a few years ago I managed to convert a file with a similar problem to grayscale tones that Blender is capable of working with, using ImageMagick. That was done with a file I got from the USGS, of data recorded by the LRO orbiter. So I'm pretty sure ImageMagick can handle it. Maybe it's 32 bit and it needs to be 16 bit, or maybe there is some other issue. (Ah - I found 'bits per sample in exiftool - it is indeed 32.)

I am asking about it on their forum, but because this matter is a bit niche, I'm also asking here because maybe people here have some insight about what's going on that will help me resolve it with the ImageMagick folks.

This is how it looks at the moment. I cropped it down to get a reasonable file size, guessing that that operation wouldn't affect anything else. How do I convert the color data for a heightmap?

enter image description here

The file came from this section of the Scientific Data area of China's Lunar and Planetary Data Release System

7
  • @user2856 I tried using exiftool to figure that out, so far it hasn't been that useful. It seems even cropping it isn't a good idea, the metadata hasn't changed, it shows what the original file had. That is a file over 30,000 pixels across. But I don't see any indication of bit depth. Commented Oct 7, 2021 at 0:30
  • Ok, it's Float32 format with elevation values probably in metres (image). Now if you can just add what you mean by "heightmap" to your question, we might be able help.
    – user2856
    Commented Oct 7, 2021 at 0:57
  • @user2856 I don't know how else to answer that question. Do you need to know what file parameters Blender expects? It never comes up. It wants colors from black to white, I don't know anything else to say about it. Commented Oct 7, 2021 at 0:59
  • I missed the blender bit. Sounds like you need a unsigned 16bit PNG with the values rescaled from actual min/max of the data to 0-65535 using the GDAL software (available for Win, Linux, MacOS) - johnflower.org/tutorial/heightmap-conversion-gdal gis.stackexchange.com/a/242808/2856
    – user2856
    Commented Oct 7, 2021 at 1:14
  • @user2856 That looked perfect. I installed it and it's given me a min/max of -3184.302, 774.906. I rounded that and tried the translate command, but it didn't like the negative number. I made that number 0 and added 3184 to 775, and put the Max number as 3959. But it gives me ERROR 6: Too many command options '0'. I left a remark. I'll see if I can try something else. Commented Oct 7, 2021 at 1:45

1 Answer 1

2

Sounds like you need a unsigned 16bit PNG with the values rescaled from actual min/max of the data to 1-65535 using the GDAL software (available for Win, Linux, MacOS):

E.g.

gdalinfo -stats CE2_GRAS_DEM_50m_A001_87N000W_A.tif
Driver: GTiff/GeoTIFF
<snip/>
Band 1 Block=128x128 Type=Float32, ColorInterp=Gray
  Min=-5051.664 Max=1592.283 
  Minimum=-5051.664, Maximum=1592.283, Mean=-1080.469, StdDev=905.434
  NoData Value=-3.40282306073709653e+38

gdal_translate -of PNG -ot UInt16 -scale -5051.664 1592.283 1 65535 CE2_GRAS_DEM_50m_A001_87N000W_A.tif CE2_GRAS_DEM_50m_A001_87N000W_A.png

enter image description here

1
  • Yes, that worked perfectly, thank you. I was also able to do it with ImageMagick, after further help from them. I am going to add an additional answer regarding that, as some people use ImageMagick a lot and may prefer it. Doing it with GDAL allows me to easily specify the range of values in the output, and I like that. Commented Oct 7, 2021 at 18:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.