Getting absolute elevation from Copernicus DEM

Hi all,

I’ve been working on trying to generate a 3D mesh from DEMs pulled from Copernicus, which would ideally be as close to the real-world equivalent in terms of measurements as possible. The problem is that the elevation values seem to be all over the place in terms of the brightness value of the pixels in the returned image.

For example, I got this DEM of table mountain in South Africa using the following code:

async function getDEM(bbox, token) {
    const response = fetch("",
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': 'Bearer ' + token,
            body: JSON.stringify({
                "input": {
                    "bounds": {
                        "properties": {
                            "crs": ""
                        "bbox": bbox
                    "data": [{
                        "type": "DEM"
                "output": {
                    "width": 1024,
                    "height": 1024,
                    "responses": [{
                        "identifier": "default",
                        "format": {
                            "type": "image/tiff"
            "evalscript": `
            //VERSION = 3

            function setup() {
                return {
                    input: ["DEM"],
                    output: {bands: 1}
            function evaluatePixel(sample) {
                return [sample.DEM/1000]
    return response

This seems to cap out the height value, since the brightest pixels values are at 255, however, a quick google search shows that Table Mountain only reaches about a kilometer in elevation. This would mean that elevation can only be between sea level and at maximum 1 kilometer, despite the documentation stating that is should be able to range between -11000 to +9000 meters.

Anyway, sorry the long winded question but does anyone have any insight into why this might be, and also how to increase the range of altitudes that can be effectively used?


As is customary in these sorts of things, mere minutes after posting this I figured out what I was doing wrong. For anyone else who gets stuck like I did, as much as i doubt there will be anyone, the pixel value is being divided by the maximum height in the lines

function evaluatePixel(sample) {
    return [sample.DEM/1000]

meaning that in order to get an absolute altitude above sea level for anywhere in the world you simply change it to

function evaluatePixel(sample) {
    return [sample.DEM/9000]

However this still presents a problem of resolution, since every brightness value for a pixel is roughly equivalent to 35m from the previous value which is less than ideal.

1 Like

Hi Sean,

Happy that you managed to find a solution to your issue.

It is also worth looking further at the examples in the documentation:

When wishing to extract the absolute altitude, it’s important to specify the sampletype in your output. By default the sample type is ‘UINT8’ (for visualisation purposes) which only outputs values between 0-255. You have to explicitly define your sampletype as ‘UINT16’ if you wish to extract the absolute values of the DEM.

If you have any other questions, do let us know and I’m sure we can help out!