0

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:

2

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.

  • Thank you very much for your fast response! How do I know what color values to set it to in greyscale? – Godforest Jun 23 '14 at 13:40
  • It is up to you. There are 51 distinct values used for depths and heights in your image with value range from -69 to 1037. Scale is not linear which probably means that you will need to post-process the data. You have only 256 values to use in the palette and you perhaps want to expand the gray scale image into 32-bit and rescale the values for making the end result linear. I guess that you can do that with QGIS and raster calculator. – user30184 Jun 23 '14 at 13:57
  • While cross referencing I realized the legend was also bogus, so I manually made a new one: link So would I now give the lowest color white and the highest black and then approriate intermediate grayscale values in the palette for everything in between? – Godforest Jun 23 '14 at 17:20
  • I suppose vice versa, low values for deep waters and high for the mountains. But I have never done that myself. Experiment a bit and you will be the master. Advice from Miro looks good. VRT system in the last example is also worth reading trac.osgeo.org/gdal/wiki/FAQRaster – user30184 Jun 24 '14 at 20:36
2

I have opened the file in QGIS and it shows as 1 band paletted raster with values (colors) from 0 to 255. After closer look to histogram it actually has only values from 5 to 25 - all the yellow-greenish colors - excluding value 23 which has zero representations. Also there is value 47 which is blank edge on the left of the raster.

So, if you can't get raster with proper values you need to use colors in your legend with values 26 - 87 and manually reclassify the raster according to these legend colors.

  1. For checking colours I would use some open source tool like color picker:

http://sourceforge.net/projects/colorfinder/

  1. For reclassification:

How to perform Raster Reclassification in QGIS?

or raster calculator like this:

("DEM_raster@1" = 5)*83 + ("DEM_raster@1" = 6)*80 + ...

Also if you can recreate the raster double check for other export/save settings/formats which could save you all this hassle. And if raster image/legend are the only option it could still help to recreate it at least in gray scale. If nothing else the values could be in order and not as the linked file where there is only some pattern but definitely interrupted...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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