Tree Canopy API

الوصول والحدودPublic, no key needed · Heavy▾

مفتوح للجميع. مفتاح API مجاني من ملفك الشخصي يرفع الحدود: أرسله في X-API-Key رأس، أو كـ api_key= في العنوان.

5 دقائقساعةيوم
بدون مفتاح20120500
مع مفتاح604002,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 بالثواني. لا تُحسب الطلبات المرفوضة.

GET لا مفتاح مطلوب ملف JSON أو ثنائي حتى 30 كم مربع خلايا بت واحد أو 4 بت 60 طلباً في الساعة لكل عنوان

أين الأشجار وكم طولها فوق مربع حول نقطة: كل خلية من مخزن الظلة حوالي 3 × 5 أمتار، نفس البيانات التي خريطة ارتفاع مظلة الأشجار الرسومات. اطلبها كـ JSON لصفحة ويب أو سكريبت، أو كملف ثنائي صغير يمكن لجهاز كمبيوتر الرحلة أو محطة الأرض حمله وقراءته ببضعة أسطر من التعليمات البرمجية، بحيث يمكن دمج أشجار موقع الإطلاق في البرنامج الثابت بدلاً من جلبها في اليوم.

GEThttps://www.altimetercloud.com/api/trees/lat lon size_km

المعاملات

معاملمعنى
lat, lonمنتصف المربع، الدرجات العشرية (lng مقبول أيضًا)
size_kmجانب المربع بالكيلومتر، أكثر من 0 وحتى 30. إذا تم حذفه، 1. المربعات التي تزيد عن 10 كم تأتي كـ format=bin فقط، وتستغرق وقتًا أطول في التحضير: حتى نصف دقيقة لـ 30 كم.
bitsاختياري. 4 (الافتراضي): كل خلية هي فئة ارتفاعها، من 0 إلى 15. 1: كل خلية 1 للأشجار بارتفاع 3 م أو أكثر و 0 لا شيء، ربع الحجم.
formatاختياري. json (الافتراضي، للمربعات حتى 10 كم): الخلايا بصيغة base64 داخل إجابة JSON مع كل شيء مطلوب لقراءتها. bin: رأس 32 بايت والخلايا، كملف، بأي حجم.
compressاختياري. none (الافتراضي), zlib أو lzma. مع format=bin the whole file is compressed; with json الخلايا قبل base64. lzma هو LZMA-alone (.lzma), مصنوع للأجهزة الصغيرة: انظر LZMA أدناه.
downloadاختياري. 1 يجعل المتصفح يحفظ format=bin الإجابة كملف، مسمى حسب المربع.

الخلايا

مربع بمساحة 1 كم بالقرب من Windermere على خريطة ارتفاع أغطية الأشجار، بجانب نفس المربع المرسوم مباشرة من تنزيل 4 بت الخاص به

مربع 1 كم بالقرب من Windermere: على اليسار كما يظهره خريطة ارتفاع مظلة الأشجار، على اليمين مرسوم مباشرة من تنزيل بـ 4 بتات، تم تلوين كل خلية حسب نطاقها وأسود حيث لا توجد أشجار.

الشبكة من متجر الأغطية نفسه، لذا لا شيء يتم إعادة عينات: كل خلية بالضبط 1/24000 من الدرجة في كل اتجاه، حوالي 4.6 م من الشمال إلى الجنوب وفي خطوط العرض البريطانية، حوالي 2.7 م من الشرق إلى الغرب. الصف 0 هو الحافة الشمالية والعمود 0 هو الحافة الغربية; rows run south and columns east. Every row starts on a whole byte, so row j يبدأ عند البايت j * row_bytes.

bitsلكل خليةالتعبئة والتغليف
4نطاق الارتفاع من 0 إلى 15خليتان بايت واحد، الأولى في أربع بتات عليا
11 = أشجار بارتفاع 3 م أو أكثر، 0 = لا شيءثماني خلايا بايت، الأولى في البت الأعلى

نطاقات الارتفاع، أقل ارتفاع في كل:

نطاق0123456789101112131415
منبلا3 m5 m7 m10 m13 m16 m19 m22 m26 m30 m35 m40 m46 m53 m61 m

الارتفاعات هي الأشجار كما كانت عند التقاط الصور الفضائية: بين 2017 و 2020، في الغالب 2018 إلى 2020، لبيانات Meta، و 2020 لإعادة التعبئة من ETH. لن تظهر الأراضي الحرجية المقطوعة أو المزروعة منذ ذلك الحين.

Band 0 is open ground, water, and anything under 3 m, including scrub and hedges. Ground not yet in the database is 0 as well; the JSON answer's sources.none تعد تلك الخلايا.

الأحجام

في خطوط العرض البريطانية، قبل الضغط:

مربعالخلايا4-بت1-bit
1 كم217 × 36839 كيلوبايت10 KB
3 كم648 × 1,102349 KB87 KB
5 كم1,079 × 1,835967 KB242 KB
10 كم2,157 × 3,6693.8 MB967 KB
20 كم4,313 × 7,33715.1 MB3.8 MB
30 كم6,469 × 11,00533.9 MB8.5 MB

Compression takes these down a long way. File sizes near Windermere in the Lake District (54°N), over mixed woodland, fells and fields; the 1, 3 and 10 km rows are real downloads, and the rows marked ~ are estimated from them:

مربع4-بت، نطاقات الارتفاع1-بت، شجرة أم لا
خامzliblzmaخامzliblzma
1 كم40 KB13 KB13 KB10 KB4 كيلوبايت4 كيلوبايت
3 كم352 KB90 KB82 كيلوبايت88 كيلوبايت28 كيلوبايت23 كيلوبايت
5 كم967 KB~250 KB~230 KB242 KB~70 KB~60 كيلوبايت
10 كم3.8 MB1.0 MB0.9 MB967 KB268 كيلوبايت217 KB
20 كم15.1 MB~4 ميجابايت~3.6 ميجابايت3.8 MB~1 ميجابايت~0.85 MB
30 كم33.9 MB~9 MB~8 MB8.5 MB~2.4 ميجابايت~1.9 ميغابايت

شيئان يحركان هذه. كلما ابتعدت عن الأقطاب، تحتاج المربع إلى أعمدة أقل، لذا تتقلص الملفات الأولية: مربع 30 كم من 4-بت عند 45°N بحجم 28.5 ميجابايت مقابل 33.9 ميجابايت هنا. والأراضي الحرجية الكثيفة تضغط بشكل أسوأ من الأرض المفتوحة: مربع حقيقي 30 كم من 4-بت في جبال الألب الفرنسية بالقرب من إيكس لي بان، معظمه مغطى بالغابات، وصل إلى 9.5 ميجابايت مع lzma, حوالي ثلث حجمه الخام، حيث انخفضت مربعات Windermere إلى حوالي ربع. lzma هو دائماً الأصغر، حوالي عُشر لـ 4-bit وخمس لـ 1-bit.

LZMA

compress=lzma يعطي تدفق LZMA وحده، ال .lzma الصيغة، وليس .xz: a 13 byte header (one properties byte, 0x5D for lc=3 lp=0 pb=2; a 4 byte dictionary size, 65536; the 8 byte uncompressed length, little endian) and then the compressed data. The 64 KB dictionary keeps the memory a decoder needs small enough for a microcontroller such as an ESP32, and the length is always the true one, so a decoder such as the LZMA SDK's LzmaDec يعرف بالضبط ما يتوقعه. على جهاز كمبيوتر, xz --format=lzma -d أو Python's lzma الوحدة مع FORMAT_ALONE فك حزمه.

الملف الثنائي

مع format=bin: رأس 32 بايت، تنسيق little endian، ثم الصفوف، الشمال أولاً.

بايتاكتبقيمة
0char[4]ACTR
4uint8الإصدار، 1
5uint8بتات لكل خلية، 1 أو 4
6uint16خلايا لكل درجة، 24000
8int32الحافة الشمالية بالخلايا: خطها × 24000
12int32الحافة الغربية بالخلايا: خطول × 24000
16uint32الصفوف
20uint32الأعمدة
24uint32بايتات لكل صف
28uint320، محجوز

الحواف عبارة عن أرقام صحيحة للخلايا، لذا تُعيّن الموضع إلى خليته بالضبط: صف north_edge - 1 - floor(lat * 24000), عمود floor(lon * 24000) - west_edge.

أمثلة

https://www.altimetercloud.com/api/trees/?lat=54.35&lon=-3.03&size_km=3
https://www.altimetercloud.com/api/trees/?lat=54.35&lon=-3.03&size_km=5&bits=1&format=bin&compress=zlib
https://www.altimetercloud.com/api/trees/?lat=54.35&lon=-3.03&size_km=10&format=bin&compress=lzma&download=1

إجابة JSON

{
  "success": true,
  "lat", "lon", "size_km", "bits",
  "rows", "cols", "cells", "row_bytes",      the grid, as above
  "cells_per_degree", "north_edge_cell", "west_edge_cell",
  "north", "south", "west", "east",          the square's edges, degrees
  "cell_deg", "cell_m_north_south", "cell_m_east_west",
  "wooded_pct",                              cells with trees of 3 m or more
  "coverage_pct",                            cells the database holds
  "sources": { "meta_chmv2", "eth_fine", "eth_medium", "eth_coarse", "none" },
  "band_min_m": [ 0, 3, 5, ... ],            bits=4
  "meaning", "order", "compress", "bytes",
  "data_b64",                                the rows, row 0 first, compressed if asked
  "file_name", "seconds",
  "credits": { "canopy", "source", "source_eth", "licence", "full" }
}

Reading the cells

On a device: what's below me

Give a position and get the cell it is in: every position falls in exactly one cell, so this is the ground directly underneath. The file sits in flash or on a card, and cells is the bytes straight after the 32 byte header. Use doubles for the position: a float's 24 bits leave only about an eighth of a cell to spare.

// C
typedef struct __attribute__((packed)) {
  char     magic[4];        // "ACTR"
  uint8_t  version;         // 1
  uint8_t  bits;            // 1 or 4
  uint16_t cells_per_deg;   // 24000
  int32_t  north_edge;      // latitude of the north edge * 24000
  int32_t  west_edge;       // longitude of the west edge * 24000
  uint32_t rows, cols, row_bytes, reserved;
} TreeHeader;

// the band (0 to 15), or 1/0 for tree or not, at a position; -1 outside the square
int treeAt(const TreeHeader *h, const uint8_t *cells, double lat, double lon) {
  int32_t j = h->north_edge - 1 - (int32_t)floor(lat * h->cells_per_deg);
  int32_t i = (int32_t)floor(lon * h->cells_per_deg) - h->west_edge;
  if (j < 0 || i < 0 || j >= (int32_t)h->rows || i >= (int32_t)h->cols) return -1;
  const uint8_t *row = cells + (uint32_t)j * h->row_bytes;
  if (h->bits == 4) { uint8_t b = row[i >> 1]; return (i & 1) ? (b & 15) : (b >> 4); }
  return (row[i >> 3] >> (7 - (i & 7))) & 1;
}

// a band's height range in metres; max_m is 0 for band 15 (61 m and over) and band 0
static const uint8_t BAND_MIN_M[16] = { 0, 3, 5, 7, 10, 13, 16, 19, 22, 26, 30, 35, 40, 46, 53, 61 };
void bandMetres(int band, int *min_m, int *max_m) {
  band &= 15;
  *min_m = BAND_MIN_M[band];
  *max_m = (band > 0 && band < 15) ? BAND_MIN_M[band + 1] : 0;
}

الأشجار القريبة مني

للهبوط: كل خلية التي وسطها ضمن دائرة نصف القطر للموضع، كم عدد الأشجار المحتفظ بها، كم المسافة إلى أقربها وأطولها بينهم. النسخة الكاملة هي treesWithin() in the reader download below; it works in metres from the cell size, which is 111320 / 24000 م من الشمال إلى الجنوب وهذا مضروب في جيب تمام خط العرض من الغرب إلى الشرق.

TreeNear t = treesWithin(h, cells, lat, lon, 50.0f);   // within 50 m
// t.wooded     cells with trees of 3 m or more
// t.cells      cells in the circle (fewer near the square's edge)
// t.nearest_m  to the nearest wooded cell, -1 if none
// t.tallest    the highest band in the circle

الأشجار والأرض

الارتفاعات المدرجة هنا هي ارتفاعات الأشجار فوق الأرض التي تقف عليها، وليس فوق مستوى سطح البحر أو فوق منصة الإطلاق الخاصة بك. لذا فإن الملف يخبرك بوجود أشجار تحتك وارتفاعها، لكنه لا يخبرك بمدى بعد قممها تحتك: فوق الوادي أو المنحدر، وهذا يعتمد على الأرض بقدر اعتماده على الأشجار. للحصول على ذلك، اجمعه مع ارتفاعات الأرض من ارتفاع التضاريس API، أو شبكة التضاريس API for a whole square to keep alongside the tree file on a device. An altimeter measures height above the pad, and the pad's ground height turns that into height above sea level; the tree tops below you are the ground height there plus the tree height.

// the pad's ground height and the ground height below you, both from the terrain APIs
double rocket_asl = pad_ground_m + height_above_pad_m;

int lo, hi;
bandMetres(treeAt(h, cells, lat, lon), &lo, &hi);
if (hi == 0 && lo > 0) hi = 70;                  // band 15 is 61 m and over: pick your own top
double canopy_asl = ground_below_m + hi;          // the top of the band, to be on the safe side
double clearance  = rocket_asl - canopy_asl;      // metres between you and the tree tops

فك الضغط على جهاز تحكم دقيق

A compress=lzma الملف يفك الضغط عنه باستخدام LzmaDecode() من LZMA SDK بقلم Igor Pavlov: ملفي C, LzmaDec.c و LzmaDec.h, المجال العام، والمفكك الذي يحمله Altimeter Cloud Jupiter. تم فكه في مرة واحدة مباشرة في المخزن المؤقت النهائي، هذا المخزن المؤقت يعمل كقاموس، لذا بما يتجاوز الملف نفسه فإنه يحتاج فقط إلى حوالي 16 كيلوبايت أثناء عمله. على ESP32, compress=zlib لا تحتاج إلى أي شيء إضافي: miniz's tinfl موجود بالفعل في ذاكرة القراءة فقط. xz-embedded ليست الخيار الصحيح: فهي تقرأ .xz, لا .lzma.

قارئ Tree و فك تشفير LZMAzip، معبأة 26/09/2026

في ملف zip: tree_reader.h و tree_reader.c مع كل ما سبق بالإضافة إلى treeUnpackLzma(), وملفات فك تشفير LZMA SDK التي تم بناء Jupiter معها. بالنسبة لـ Arduino، انسخها إلى مجلد الرسم وأضفها #include "tree_reader.h"; the LZMA part builds itself only when the SDK files are there. They were current on that date; for anything newer, check the صفحة LZMA SDK.

على جهاز كمبيوتر

# Python
import requests, struct, zlib, numpy as np
r = requests.get('https://www.altimetercloud.com/api/trees/',
                 params={'lat': 54.35, 'lon': -3.03, 'size_km': 3, 'format': 'bin', 'compress': 'zlib'})
f = zlib.decompress(r.content)            # or lzma.decompress(r.content, format=lzma.FORMAT_ALONE)
magic, ver, bits, cpd, north, west, rows, cols, rb, _ = struct.unpack('<4sBBHiiIIII', f[:32])
g = np.frombuffer(f[32:], np.uint8).reshape(rows, rb)
if bits == 4:
    cells = np.empty((rows, rb * 2), np.uint8); cells[:, 0::2] = g >> 4; cells[:, 1::2] = g & 15
else:
    cells = np.unpackbits(g, axis=1)
cells = cells[:, :cols]                       # row 0 north, column 0 west
lat_of_row = lambda j: (north - j - 0.5) / cpd
lon_of_col = lambda i: (west + i + 0.5) / cpd

الأخطاء

تعود الأخطاء كـ JSON مع "success": false, رمز ورسالة.

الرمزمعنى
412معامل مفقود أو غير صالح، أو المربع أكبر من 30 كم، أو تم طلب JSON فوق 10 كم
413المربع يحتوي على عدد كبير جدًا من الخلايا، وهو ما يحدث فقط بالقرب من القطبين
429عدد كبير جدًا من الطلبات من عنوانك، أو لا يزال هناك طلب قيد المعالجة
501الضغط المطلوب غير متوفر الآن

جربها

ال خريطة ارتفاع مظلة الأشجار لديها لوحة تنزيل: انقل الخريطة بحيث يجلس الصليب على موقع الإطلاق الخاص بك، واختر الحجم والخلايا والضغط، وحفظ الملف من هذه API.

Canopy data credits

Canopy heights: Meta and World Resources Institute (WRI) 2026, Version 2 High Resolution Canopy Height Maps (CHMv2), source imagery for CHM © 2016 Vantor, licensed under CC BY 4.0. Where that is not yet in the database: ETH Global Canopy Height 2020, Lang, Jetz, Schindler and Wegner, ETH Zurich, CC BY 4.0. Both are reduced here to the height bands above, which changes them: they are not the original data.

إعادة أفضال 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.