[GIS] Retrieving Elevation from Color in Raster DEM

colordemglobal-mapperqgisraster

I'm fairly new to GIS work.

I have a DEM in raster format, that is unfortunately not properly meta-referenced. In other words it has a legend where each color is assigned with the respective elevation, but no program I have could work with it.
So what I think I need to do is, assign each color the respective elevation value and then turn it into a proper DEM to work with (the terminal result should be a *.XYZ file).
But I don't really know how…

Programs I use(d):

  • QGIS
  • Global Mapper
  • JOSM
  • L3DT

The DEM file with and without legend:

Best Answer

There may be some more clever ways to do the job but if it is just this one image I would do it manually. First take a gdalinfo report. It will show you the palette which looks like this:

gdalinfo dem_raster.tif
....
Band 1 Block=19374x1 Type=Byte, ColorInterp=Palette
  Color Table (RGB with 256 entries)
    0: 0,0,0,255
    1: 58,0,0,255
    2: 102,0,0,255
    3: 144,58,0,255
    4: 182,102,0,255
    5: 168,168,0,255
    6: 173,173,0,255
    7: 167,176,0,255
    8: 179,179,0,255
    9: 166,181,0,255
...

You have the legend and according to that you can manually edit the palette into a grey scale palette. Once you are ready convert the paletted image into RGB with http://gdal.org/pct2rgb.html. Use gdal_transform with -b 1 and write out a single band grey scale tif and I guess it can be used as DEM.

Related Question