som
som

Reputation: 2477

Mapbox Terrain: Reference DEM values in a Style expression

Is it possible to retrieve DEM elevation values for use in a Mapbox Style expression?

Case in point - I'm using a custom DEM for terrain in Mapbox GL-JS. I would like to set the exaggeration based on the elevation value (lower terrain, higher exaggeration) via an interpolate expression.

// Pseudo code
map.setTerrain({
  source: 'custom-dem',
  exaggeration: [
    'interpolate',
    ['linear'],
    ['get', 'z'], // ???
    0, 2.5,
    100, 1.5,
  ],
});

Upvotes: 0

Views: 632

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126457

I don't think there is any mechanism to retrieve the height of terrain within an expression, so no.

In any case, according to the documentation the terrain type only has basic functionality (ie, not data-driven expressions), so you can't do what you're trying to do for that reason, too.

Upvotes: 0

Related Questions