To find the elevation of a location, you use the ArcGIS Elevation service. The Elevation service is a location service that returns elevation values for a single location or multiple locations. Elevation coverage is provided for both topography (land elevations) and bathymetry (water depths) and takes location inputs as longitude and latitude coordinates. All elevation values will be returned in meters as measures of ellipsoidal height above ground level or orthometric height above mean sea level.
You can build applications that use the service to:
- Determine the height of a specific location above mean sea level or ground level.
- Measure the depth of a water body at a specific location.
- Compare the relative elevation of different points to determine slope.
- Plan flight paths by assessing elevation changes along a route.
- Create elevation profiles of trails or roads.
How to access the Elevation service
The Esri Leaflet plugin does not provide direct integration for accessing the Elevation service. Instead, you use the ArcGIS REST JS elevation
and request
packages to make an authenticated request to the service.
- Reference the Esri Leaflet plugin.
- Reference the
elevation
andrequest
packages to make an authenticated request to the service. - Set up authentication.
- If you are using an API key, make sure it has privileges to access the Elevation service.
- If you are using user authentication, the account must be an ArcGIS Location Platform account with Elevation service privileges.
- Define parameters to pass to the service.
- Call the service and handle the results.
Example
Find the elevation of a point
This example illustrates how to get elevation data of a specific location.
let circleMarker = null;
map.on("click", async (e) => {
const { lat, lng } = e.latlng;
if (circleMarker) {
map.removeLayer(circleMarker);
}
circleMarker = L.circle([lat, lng], {
color: "#00000",
fillColor: "#FF0000",
radius: 75,
fillOpacity: 1
}).addTo(map);
const response = await arcgisRest.findElevationAtPoint({
lon: lng,
lat: lat,
relativeTo: elevationMeasure,
authentication: arcgisRest.ApiKeyManager.fromKey(accessToken)
});
const { x, y, z } = response.result.point;
L.popup()
.setLatLng(e.latlng)
.setContent(
`<b>Elevation relative to ${elevationMeasure === "meanSeaLevel" ? "mean sea level" : "ground level"}</b><br>
Latitude: ${y.toFixed(5)}<br>
Longitude: ${x.toFixed(5)}<br>
Elevation: ${z} m`
)
.openOn(map);
});
Find the elevations of multiple points
This example illustrates how to get elevation values of multiple locations at once.
async function displayElevationData() {
const data = await arcgisRest.findElevationAtManyPoints({
coordinates: points,
authentication: arcgisRest.ApiKeyManager.fromKey(accessToken)
});
const elevationValues = data.result.points.map((point) => point.z);
points.forEach(([lng, lat], index) => {
L.marker([lat, lng])
.addTo(map)
.bindTooltip(`${elevationValues[index]} m`, { permanent: true, direction: "top", offset: [-15, -10] })
.openTooltip();
});
}
displayElevationData();