Terrain Grid API
الوصول والحدودPublic, no key needed · Heavy▾
مفتوح للجميع. مفتاح API مجاني من ملفك الشخصي يرفع الحدود: أرسله في X-API-Key رأس، أو كـ api_key= في العنوان.
| 5 دقائق | ساعة | يوم | |
|---|---|---|---|
| بدون مفتاح | 20 | 120 | 500 |
| مع مفتاح | 60 | 400 | 2,000 |
Each 100 square km of area counts as one request, so a 10 km square is 1 and a 30 km square is 9.
قم بتسجيل الدخول لإنشاء مفتاح مجاني على صفحة ملفك الشخصي.
كل إجابة تحمل X-RateLimit-Remaining و X-RateLimit-Reset. تجاوز الحد، الإجابة خطأ 429 مع retry_after بالثواني. لا تُحسب الطلبات المرفوضة.
كل ارتفاع أرضي فوق منطقة في طلب واحد، من نفس مخزن التضاريس كما هو الحال في ارتفاع التضاريس API وإعطاء نفس الارتفاعات. استخدمه للخرائط والنماذج ثلاثية الأبعاد ودراسات المسار بدلاً من طلب النقاط واحدة تلو الأخرى.
lat lon size_kmالمعاملات
امنح المنطقة بإحدى طريقتين: منتصفها وحجمها، أو حوافها.
| معامل | معنى |
|---|---|
lat, lon | منتصف المنطقة، بالدرجات العشرية (lng مقبول أيضًا) |
size_km | منطقة مربعة بحجم هذا الحد الكثير من الكيلومترات على كل جانب، حتى 100 |
width_km, height_km | بدلاً من size_km: مستطيل، من الشرق إلى الغرب ومن الشمال إلى الجنوب، يصل طول كل منهما إلى 100 كم |
north, south, west, east | بدلاً من المنتصف والحجم: حواف المنطقة بالدرجات العشرية، حتى 100 كم في كل اتجاه. يمكن أن يكون الصندوق عبر 180 درجة east أقل من west. |
spacing_m | اختياري. أمتار بين النقاط، من 30 إلى 5000. إذا تُرك بدون تحديد، أدق تباعد يحافظ على الشبكة عند 1,000,000 نقطة: 30 م للمناطق التي تبلغ حوالي 30 كم، حوالي 100 م لـ 100 كم. |
format | اختياري. json (الافتراضي) أو asc, شبكة ASCII من ESRI التي يفتحها برنامج GIS مثل QGIS مباشرة |
encoding | اختياري، لـ JSON. base64 (الافتراضي): الارتفاعات كقيم ثنائية معبأة، مضغوطة وسهلة فك الترميز، معبأة كـ pack يقول. array: الارتفاعات كقوائم متداخلة من الأرقام إلى 0.1 م، سهلة القراءة لكنها أكبر عدة مرات. |
pack | اختياري، للقاعدة 64. كيفية ضغط كل ارتفاع: uint16 (الافتراضي), int16 أو float32. انظر التعبئة والتغليف أدناه. |
التعبئة والتغليف
مع ترميز base64 الافتراضي تأتي الارتفاعات كمجموعة واحدة من قيم ثنائية، little endian، قيمة واحدة لكل نقطة. اختر التعبئة التي تناسب المنطقة:
pack | بايت لكل ارتفاع | الارتفاع بالأمتار | الدقة | النطاق | 1,000,000 نقطة |
|---|---|---|---|---|---|
uint16 (افتراضي) | 2 | value * 0.1 - 100 | 0.1 m | -100 m إلى 6,453.5 m | حوالي 2.7 MB |
int16 | 2 | value | 1 m | كل ارتفاع على الأرض | حوالي 2.7 MB |
float32 | 4 | value | الدقة الكاملة | كل ارتفاع على الأرض | حوالي 5.3 ميجابايت |
الافتراضي مناسب لكل مكان تقريبًا حيث يطير الناس. ارتفاع خارج نطاقه، مثل ساحل بحر الميت (حوالي 430 م تحت مستوى سطح البحر) أو قمة أعلى من 6453 م، يتم تعيينه إلى الحد الأقرب ويتم احتسابه في pack.clamped, مع note_clamped saying so; ask for int16 أو float32 هناك. الإجابة تقول دائمًا كيفية تعبئتها pack, حتى يتمكن الكود من القراءة scale و offset منه بدلاً من افتراضها.
A grid can hold at most 1,000,000 points. The finest spacing is 30 m, the resolution of the best terrain the store holds; where the store is coarser, closer points simply interpolate between its values.
أمثلة
https://www.altimetercloud.com/api/terrain_grid/?lat=54.45&lon=-3.05&size_km=10&spacing_m=100
https://www.altimetercloud.com/api/terrain_grid/?north=54.6&south=54.4&west=-3.2&east=-2.9&spacing_m=250&encoding=array
https://www.altimetercloud.com/api/terrain_grid/?lat=54.45&lon=-2.95&size_km=4&spacing_m=100&format=asc
كيفية تخطيط الإجابة
الشبكة عادية بخط العرض والطول. الصف 0 هو الحافة الشمالية والعمود 0 هو الحافة الغربية; rows run south and columns run east, and the point in row j, عمود i يقع في خط العرض north - j * lat_step وخط الطول west + i * lon_step. الخطوات هي المسافة المطلوبة، بالمتر، في منتصف المنطقة.
{
"success": true,
"rows", how many rows, north to south
"cols", "points_per_row", how many points in each row, west to east (the same number)
"points", rows * cols
"north", "south", "west", "east", the first and last rows and columns, degrees
"lat_step", "lon_step", degrees between rows and between columns
"spacing_m", "width_km", "height_km",
"min_m", "max_m", lowest and highest height in the grid
"tiers": { "ultra", "fine", "medium", "coarse", "none" }, how many points came from each resolution
"encoding",
"pack": { "type", "bytes_per_value", "scale", "offset", "formula",
"resolution_m", "byte_order", "clamped" }, encoding=base64
"heights_b64", encoding=base64: rows * cols packed values, row 0 first
"note_clamped", only when some heights were outside the packing's range
"heights": [ [ ... ], [ ... ] ], encoding=array: one list per row, north first, to 0.1 m
"order", "datum", "units", "no_data", "seconds",
"credits": { "terrain", "full_statements", "attribution", "source" }
}
الارتفاعات بالمتر فوق متوسط سطح البحر (EGM96). البحر وأي مكان ليس لديه المتجر بيانات عنه هو 0، وتُحسب هذه النقاط في tiers.noneارتفاع الصف j, عمود i هو قيمة الرقم j * cols + i.
قراءة الارتفاعات
// JavaScript
const d = await (await fetch('https://www.altimetercloud.com/api/terrain_grid/?lat=54.45&lon=-3.05&size_km=10')).json();
const bytes = Uint8Array.from(atob(d.heights_b64), c => c.charCodeAt(0));
const P = d.pack; // typed arrays are little endian on nearly every machine
const raw = P.type === 'uint16' ? new Uint16Array(bytes.buffer)
: P.type === 'int16' ? new Int16Array(bytes.buffer)
: new Float32Array(bytes.buffer);
const heightAt = (row, col) => raw[row * d.cols + col] * P.scale + P.offset;
const latOf = row => d.north - row * d.lat_step;
const lonOf = col => d.west + col * d.lon_step;
# Python
import base64, requests, numpy as np
d = requests.get('https://www.altimetercloud.com/api/terrain_grid/',
params={'lat': 54.45, 'lon': -3.05, 'size_km': 10}).json()
P = d['pack']
dtype = {'uint16': '<u2', 'int16': '<i2', 'float32': '<f4'}[P['type']]
h = np.frombuffer(base64.b64decode(d['heights_b64']), dtype=dtype).reshape(d['rows'], d['cols']) * P['scale'] + P['offset']
lats = d['north'] - np.arange(d['rows']) * d['lat_step']
lons = d['west'] + np.arange(d['cols']) * d['lon_step']
شبكة ESRI ASCII
مع format=asc الإجابة عبارة عن نص عادي: رأس قصير، ثم سطر واحد لكل صف، الشمال أولاً، مع ارتفاع واحد لكل عمود، إلى 0.1 م. بعيداً عن خط الاستواء، النقاط ليست مربعة بالدرجات، لذا يعطي الرأس الخطوات كـ dx و dy, الذي يقرأه GDAL و QGIS. الإحداثيات هي خط العرض والطول WGS 84 (EPSG:4326). الصيغة لا تترك مجالاً للأرصدة، لذا فإنها تأتي في X-Data-Credits و Link رؤوس الإجابة.
ncols 41
nrows 41
xllcenter -2.98090096
yllcenter 54.43203378
dx 0.0015450478
dy 0.0008983112
nodata_value -32768
256.9 261.7 265.6 268.3 270 271 271 270.2 ...
264.9 269.4 273.6 276.9 278.7 279.7 280.1 279.3 ...
...
الأخطاء
تعود الأخطاء كـ JSON مع "success": false, رمز ورسالة.
| الرمز | معنى |
|---|---|
412 | المعامل مفقود أو غير صحيح، أو المنطقة أكبر من 100 كم على الجانب |
413 | The spacing asked for would give more than 1,000,000 points; least_spacing_m يعطي الأفضل الذي يناسب المنطقة |
429 | عدد كبير جدًا من الطلبات من عنوانك، أو لا يزال هناك طلب قيد المعالجة |
جربها
خط العرض من الوسط
خط الطول من الوسط
الحجم (كم، حتى 100)
المسافة (أمتار، 30 إلى 5000، أو اترك فارغًا)
صيغة (json أو asc)
التعبئة والتغليف (uint16 أو int16 أو float32)
صنع بهذه البيانات: خريطة ثلاثية الأبعاد
هذا مثال على شيء مبني من الشبكة، وليس جزءاً من API. API ترجع فقط شبكة الارتفاعات. هنا متصفحك يطلب من API شبكة (طلب واحد، محسوب في حدك كل ساعة)، تحويل الارتفاعات إلى سطح ثلاثي الأبعاد مع three.js, وتغطي خرائط صور من خدمات أخرى فوقها: نفس الأسلوب المستخدم في الآراء ثلاثية الأبعاد في أدوات Altimeter Cloud الخاصة بنا. يعيد تغيير الخريطة بعد ذلك استخدام نفس الارتفاعات.
خط العرض من الوسط
خط الطول من الوسط
الحجم (كم، حتى 40 لهذا المثال)
إعادة أفضال Altimeter Cloud
مجاني الاستخدام. إذا كنت تستخدم this API, or anything made from the answers, in a commercial product or service, credit AltimeterCloud with a link to www.altimetercloud.com عند نقطة الاستخدام: على الشاشة أو الصفحة أو المطبوعة حيث تظهر البيانات، على سبيل المثال “Data from AltimeterCloud.com”. Any credits the data's own sources ask for, listed on this page, apply as well.
Terrain data credits
The ground heights come from the Terrain Tiles dataset (Mapzen / Tilezen, on AWS Open Data), reduced into resolution tiers by Altimeter Cloud. Wherever you show heights from this API, credit their sources. Each answer carries a short form of the list below in its credits field.
- ArcticDEM terrain data DEM(s) were created from DigitalGlobe, Inc., imagery and funded under National Science Foundation awards 1043681, 1559691, and 1542736
- Australia terrain data © Commonwealth of Australia (Geoscience Australia) 2017
- Austria terrain data © offene Daten Österreichs – Digitales Geländemodell (DGM) Österreich
- Canada terrain data contains information licensed under the Open Government Licence – Canada
- Europe terrain data produced using Copernicus data and information funded by the European Union - EU-DEM layers
- Global ETOPO1 terrain data U.S. National Oceanic and Atmospheric Administration
- Mexico terrain data source: INEGI, Continental relief, 2016
- New Zealand terrain data Copyright 2011 Crown copyright (c) Land Information New Zealand and the New Zealand Government (All rights reserved)
- Norway terrain data © Kartverket
- United Kingdom terrain data © Environment Agency copyright and/or database right 2015. All rights reserved
- United States 3DEP (formerly NED) and global GMTED2010 and SRTM terrain data courtesy of the U.S. Geological Survey
The licences behind each statement are on the terrain tiles attribution page.



















