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|.... Each point counts as one request. |
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 "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)).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}, timeout=10)
for item in r.json()["results"]:
print(item["elevation_m"])Response
{
"status": "ok",
"results": [
{ "lat": 36.2381, "lon": -116.8175, "elevation_m": -85.4, "resolution_m": 30 },
{ "lat": 31.559, "lon": 35.4732, "elevation_m": -430.2, "resolution_m": 30 }
]
}Response fields
| Field | Type | Description |
|---|---|---|
results | array | One entry per point, in input order. |
results[].elevation_m | number or null | Metres above mean sea level, one decimal. Negative below sea level. null over open ocean. |
results[].resolution_m | integer | Cell size of the dataset that answered: 30 or 90. |
Notes
- Values are interpolated between cells. Vertical accuracy is typically within a few metres on open terrain, worse under tree canopy and in dense cities.
- 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.
Errors
400 invalid_request when neither a point nor locations is given, when a coordinate is out of range or malformed, or when there are more than 100 points.