Learn how to access and analyze elevation data and generate contour lines for your areas of interest.
To retrieve elevation data for your area of interest:
POST
https://observearth.com/api/dem/
{
"geometry_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"format": "png",
"colormap": "greys"
}
Parameter | Type | Required | Description |
---|---|---|---|
geometry_id | UUID | Yes | UUID of your Area of Interest |
format | string | No | Output format (png, tif), default is png |
colormap | string | No | Color palette for visualization (e.g., "greys") |
import requests
import json
from PIL import Image
from io import BytesIO
api_key = "your_api_key_here"
url = "https://observearth.com/api/dem/"
payload = {
"geometry_id": "123e4567-e89b-12d3-a456-426614174000",
"format": "png",
"colormap": "terrain"
}
headers = {
"X-API-Key": api_key,
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
if payload["format"] == "png":
# Save and display the image
with open("elevation.png", "wb") as f:
f.write(response.content)
# Display the image
img = Image.open(BytesIO(response.content))
img.show()
print("Elevation image saved as elevation.png")
else:
# Save as GeoTIFF
with open("elevation.tif", "wb") as f:
f.write(response.content)
print("Elevation data saved as elevation.tif")
else:
print(f"Error: {response.status_code}")
print(response.text)
Contour lines connect points of equal elevation and are useful for visualizing terrain:
GET
https://observearth.com/api/contours/
[Image: Contour lines overlaid on a satellite image]
Contour lines overlaid on a satellite image showing terrain features.
[Image: 3D visualization with contour lines]
3D visualization with contour lines enhancing terrain perception.
Parameter | Type | Required | Description |
---|---|---|---|
geometry_id | UUID | Yes | UUID of your Area of Interest |
interval | number | No | Contour interval in meters, default is 50 |
format | string | No | Output format (geojson, shapefile), default is geojson |
Now that you understand how to work with Digital Elevation Models, you can: