Elevation lookup
Metres above mean sea level for one or many points.
GEThttps://api.mygeocode.com/v1/elevation
Parameters
| Parameter | Type | Description |
|---|---|---|
lat, lonrequired* | number | A single point. |
locationsrequired* | string | *Alternative to lat and lon: up to 100 points as lat,lon|lat,lon|... or as an encoded polyline enc:.... Each point counts as one request. |
path, samplesoptional | string, integer | *Alternative to lat and lon: samples points (2 to 100) evenly spaced along the path lat,lon|lat,lon|..., first and last point included. Answered like locations. |
bounds, rows, colsoptional | string, integer | *Alternative to lat and lon: a grid of rows by cols points (each at least 2, at most 100 points in all) over south,west,north,east, southern row first, west to east. Answered like locations. |
keyoptional | string | API key, if not sent as a header. |
The endpoint also accepts POST with a JSON body {"locations": [[lat, lon], ...]} for long lists that would not fit in a URL.
Example
$ curl -H "X-API-Key: YOUR_KEY" "https://api.mygeocode.com/v1/elevation?locations=36.2381,-116.8175|31.5590,35.4732"const points = [[36.2381, -116.8175], [31.5590, 35.4732]];
const url = new URL("https://api.mygeocode.com/v1/elevation");
url.searchParams.set("locations", points.map((p) => p.join(",")).join("|"));
const { results } = await (await fetch(url, { headers: { "X-API-Key": "YOUR_KEY" } })).json();
results.forEach((r) => console.log(r.elevation_m));import requests
points = [(36.2381, -116.8175), (31.5590, 35.4732)]
locations = "|".join(f"{lat},{lon}" for lat, lon in points)
r = requests.get("https://api.mygeocode.com/v1/elevation", params={"locations": locations}, headers={"X-API-Key": "YOUR_KEY"}, timeout=10)
for item in r.json()["results"]:
print(item["elevation_m"])Response
{
"status": "ok",
"results": [
{ "lat": 36.2381, "lon": -116.8175, "elevation_m": -82.0, "resolution_m": 463.8 },
{ "lat": 31.559, "lon": 35.4732, "elevation_m": -416.0, "resolution_m": 463.8 }
]
}Response fields
| Field | Type | Description |
|---|---|---|
results | array | One entry per point, in input order. |
results[].lat, results[].lon | number | The point, as sent or as computed along a path or grid. |
results[].elevation_m | number or null | Metres above mean sea level, one decimal. Negative below sea level, including the sea floor over open ocean (the dataset carries bathymetry). null only where the dataset has no value. |
results[].resolution_m | number | Grid spacing of the dataset in metres: 463.8 (15 arc-seconds). |
Notes
- Values come from the nearest cell of a 15 arc-second grid (about 460 m), global, land and sea floor. Expect the height of the surrounding terrain rather than a spot height: fine for profiles, catchments, radio paths and sanity checks, too coarse for a single building or a narrow ridge. Vertical accuracy is typically within a few metres on gentle terrain and tens of metres in steep mountains.
- Over water bodies inland (lakes, reservoirs) the value is the surface elevation.
- Elevation does not change. Cache results for as long as you like.
- The Google Elevation, Bing Elevations and Open-Elevation request formats are available on the drop-in hosts.
The same lookup in other providers' formats
If you already have code written against one of these providers, keep it: the drop-in host accepts the same path and parameters and answers in that provider's response shape, with this endpoint behind it. See how the drop-ins work.
| Provider | Host | Path |
|---|---|---|
| Google Maps Platform | gapi.mygeocode.com | /maps/api/elevation/json?locations=lat,lng|lat,lng/maps/api/elevation/json?locations=enc:POLYLINE/maps/api/elevation/json?path=lat,lng|lat,lng&samples=N |
| Bing Maps REST Services | bing.mygeocode.com | /REST/v1/Elevation/List?points=lat,lon,lat,lon/REST/v1/Elevation/Polyline?points=lat,lon,lat,lon&samples=N/REST/v1/Elevation/Bounds?bounds=S,W,N,E&rows=R&cols=C (GET or POST) |
| MapQuest | mapquest.mygeocode.com | /elevation/v1/profile?latLngCollection=lat,lng,lat,lng&shapeFormat=raw&unit=m |
| Open-Elevation | openelevation.mygeocode.com | /api/v1/lookup?locations=lat,lon|lat,lon/api/v1/lookup (POST, JSON body) |
Errors
400 invalid_request when neither a point nor locations is given, when a coordinate is out of range or malformed, when there are more than 100 points, or when samples, rows or cols would produce more than 100. 503 backend_unavailable when the elevation service does not answer; nothing is counted.