# How to make use of a 3 band DEM for analysis?

I have a 3-band RGB DEM raster. However, the pixel values are not very useful for any actual depth computations. How can I extract the depth values from the DEM?

I understand that it is not easy to decode the encoded colour map but I was still wondering if there was a workaround for it. I would ideally have to convert the 3-band DEM to grayscale using QGIS but the labels were broken. If it helps I know the range of possible depths (ie. minimum and maximum) in meters but I was unable to get QGIS to label it accordingly.

Edit - Some screenshots

I am not sure what all of the terminology means but I know that the 3 bands are not very useful to get the actual depth information needed, or at least I don't know how. I am working with python and I intend to convert the DEM to a numpy array and then work on it how I would work with any other image in python.

• Are you sure it's a DEM at all and not simply a colored topographical map? Can you provide the file or an extract of it or at least post a sreenshot? Jun 4 at 8:48
• @user2856 One of the DEMs I am using is colored (as in yellow, green, blue etc.) are visible on it but the rest of them appear just gray or black when opened on QGIS. However they do have 3 RGB bands for some reason which I am not sure what to do with. I will upload some screenshots Jun 4 at 9:56
• @Babel I have attached the screenshots Jun 4 at 10:04
• @user2856 also from the information tab it says it is actually a 4 band raster but I figured the 4th band was irrelevant Jun 4 at 10:05

## 1 Answer

From your screenshot, the answer is simple: you don't have a DEM. A DEM (digital elevation model) is a (most often singleband) raster where pixel values correspond to elevation. In your case, however, you have a multiband raster where pixel values correspond to color, not elevation values. The colors should visually represent terrain/topography, but does not represent elevation data.

#### Solution

Since QGIS 3.24, there is a pre installed link to a XYZ tiles service with a worldwide DEM called Mapzen Global terrain, see here and here. You can download the extent for your region of interesent and use this as a DEM. There are many other (freely available) DEM's out there, depending on your region of interest. Use those if you want to work with a DEM.

• Ah, thank you for letting me know. I do have some other rasters which can be classified as DEMs according to your definition (grayscale, single band) but their pixel values and labels are odd and do not correspond to the actual min max values (as obtained from the metashape report). Am I allowed to change the labels for min and max and will qgis just figure out the interpolation. Jun 4 at 10:37
• Not sure what you mean... maybe you post this as a separate question if it takes too long to explain. A DEM should have pixel values corresponding to elevation - so if the lowest point in the raster is at sea level, the min pixel value is 0 and if the highest point is Mount Everest, the max pixel value should be around 8848 m. For visualization, you can set a color ramp that only colors a certain spectre out of the total range, if that is what you mean? Jun 4 at 11:11
• If you refer to the min 125/max 255 values in your 2nd screenshot, that are just color values. Try to change them, but you can't get any meaningful elevation data. A cumbersome workaround would be to (manually) assign rough elevation value to each RGB combination in the palette and like this get an approximation to elevation. But that would be very inexact. If you want to use elevation values, get yourself a proper DEM as there are data available: no need for non-standard, complicated auxiliary constructions. If you don't have the data, get them, don't try to somehow construct them yourself. Jun 4 at 12:31
• The visualization is not important to me. I only want the pixel values to correspond to the correct height. i will post a new question to clear it up. Jun 4 at 12:47
• OK, short answer: as far as I can see, from the raster you have, you can't get correct elevation data, as it was not designet for this use. You must use another dataset. Jun 4 at 12:49