Creating a custom evaluation of a digital elevation model (DEM)

DEM values are in meters. They can be negative for areas below sea level, such as ocean areas.

To keep negative values, set the output format in your evalscript to sampleType: SampleType.FLOAT32 or sampleType: SampleType.INT16. Unsigned output types, such as UINT8 and UINT16, can misinterpret negative values. For example, in UINT16 a height of -15 meters is encoded as 65520.

If you need an unsigned output type, add a constant to the DEM values, for example 12000. The minimum DEM value is not smaller than -11000 meters, so the output stays positive. Subtract the same constant from the output values to get the original heights.

To implement your own visualization, write a script like this example, which shows areas above sea level in green and areas below sea level in blue:

//VERSION=3
function setup() {
  return {
    input: ["DEM"],
    output: { bands: 3 }
  }
}
function evaluatePixel(sample) {
  if (sample.DEM > 0) {
    return [0, sample.DEM / 1000, 0]
  } else {
    return [0, 0, -sample.DEM / 100]
  }
}

For more information, see Digital Elevation Model (DEM) and Digital Elevation Model (DEM) Examples.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.