Global elevation data

Mapbox
maps for developers
2 min readOct 27, 2016

By Matt Greene

Our new global elevation layer, Terrain-RGB, is live! Encoded in the Red, Green, and Blue channels of these PNG tiles are raw height values in meters. You can use the elevation data stored within Terrain-RGB for a wide variety of applications both visual and analytical, from styling terrain slope and hillshades to generating 3D terrain for video games.

Left: raw RGB, Center: decoded to hypsometric tint, Right: decoded to hillshades

Terrain-RGB uses each color channel as a position in a base-256 numbering system, allowing for 16,777,216 unique values. We’ve mapped these to 0.1 meter height increments, which gives us the vertical precision necessary for cartographic and 3D applications.

Use this endpoint to get Terrain-RGB tiles:

https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token={your-api-token}

Use this equation to decode pixel values to height values:

height = -10000 + ((R * 256 * 256 + G * 256 + B) * 0.1)

In the following example we’ve used Terrain-RGB to build a dynamic inundation mapping application that visualizes the impact of a rising sea-level. As tiles load, they are decoded and filtered; any pixel under the inundation elevation is colored blue to show areas underwater.

The San Francisco Bay area under 10 meters of water.

Western British Columbia with a Sea Level Rise of 500 meters. While this scenario is obviously dramatic, the landscape patterns that are revealed are striking.

The Gulf Coast with a Water Level of 1 meter above Sea Level.

Elevation brings with it a third dimension. You can use Terrain-RGB to generate 3D meshes and surfaces in your application of choice.

3D mesh wireframe in Unity made with Terrain-RGB

We’ve been having a blast using Terrain-RGB in Unity. You can see the new elevation layer in action, recreating the hills of San Francisco, in Camilla’s “Drive around your map” post.

Watch for more on Mapbox + Unity on the blog and at Unite LA next week! Find us at the conference or drop us a line @Mapbox to talk more about maps and Unity.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Written by Mapbox

mapping tools for developers + precise location data to change the way we explore the world

Responses (4)

What are your thoughts?

I am new to Mapbox. Where is the documentation that cover the {z}/{x}/{y} syntax?

--

Hi Sir!
Please let me know on how to implement this of on how to decode to hypsometric tint using the given equation.. how will I apply that equation? Thanks!

--

Are the RGB values expected to be 0–256? 0–1? What range is expected?

--