Calculate elevation profile
- Last UpdatedMay 6, 2025
- 1 minute read
To obtain the elevation of a route, specify return=elevation
in addition to return=polyline
in your route request.
This will result in a 3D polyline
field in each section. This polyline is encoded using a flexible polyline.
You can decode this polyline using:
- Implementations in various languages available in the flexible polyline repository.
- Maps API for Javascript: Please see the JS API Routing example on how the flexible-polyline is used.
- Command-line interfaces like flexpolyline.
The decoded polyline will consist of a series of 3D coordinates (latitude, longitude, elevation)
, with elevation represented as meters above sea-level in the WGS84 coordinate system.
The polyline decodes to:
echo BGwynmkDu39wZvBtF3InfvHrdvHvboGzF0FnGoGvHsOvR8L3NkSvWoGvHsEzFgFvHkD3IwHrJwHrJgKjN4D_E0ezoBjInV3N_iBzJ_Z | flexpolyline decode --original-precision
{(6, 1, 3);
[(52.530984, 13.384567, 74.0),
(52.530960, 13.384480, 74.0),
(52.530820, 13.383980, 74.0),
(52.530700, 13.383510, 74.0),
(52.530580, 13.383070, 74.0),
(52.530680, 13.382980, 74.0),
(52.530770, 13.382880, 74.0),
(52.530870, 13.382760, 75.0),
(52.531100, 13.382480, 75.0),
(52.531290, 13.382260, 75.0),
(52.531580, 13.381900, 75.0),
(52.531680, 13.381780, 75.0),
(52.531750, 13.381690, 75.0),
(52.531830, 13.381570, 75.0),
(52.531880, 13.381430, 75.0),
(52.532000, 13.381280, 75.0),
(52.532120, 13.381130, 75.0),
(52.532280, 13.380920, 75.0),
(52.532340, 13.380840, 75.0),
(52.532830, 13.380190, 75.0),
(52.532700, 13.379850, 75.0),
(52.532480, 13.379290, 75.0),
(52.532326, 13.378874, 75.0), ]}