Tree Canopy API
גישה והגבלותPublic, no key needed · Heavy▾
פתוח לכולם. מפתח API חינמי מהפרופיל שלך מגביל את הגבולות: שלח אותו ב- X-API-Key כותרת, או כ api_key= בכתובת.
| 5 דקות | Hour | יום | |
|---|---|---|---|
| ללא מפתח | 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 בשניות. בקשות שנדחו אינן סופרות.
איפה העצים, וכמה גבוהים, על פני ריבוע סביב נקודה: כל תא של חנות הכיפה, בערך 3 על 5 מטר, אותם נתונים ה מפת גובה כתר העץ שרטוטים. בקש עבורו ב-JSON לעמוד ویב או סקריפט, או כקובץ בינארי קטן שמחשב טיסה או תחנת קרקע יכול להוביל ולקרוא בכמה שורות קוד, כך שיערות באתר הפתילה יכול להיבנות בתוך firmware ולא להיאסף ביום.
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: משמאל כפי שמציג ה-Tree Canopy Height Map, מימין מצויר ישירות מהורדה של 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 | שני תאים בתים, הראשון בארבע ביטים גבוהים |
1 | 1 = עצים בגובה 3 מ' או יותר, 0 = אין | שמונה תאים בבית, הראשון בחלק העליון |
רצועות הגובה, גובה נמוך ביותר בכל אחת:
| להקה | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| מ | אין | 3 m | 5 m | 7 m | 10 m | 13 m | 16 m | 19 m | 22 m | 26 m | 30 m | 35 m | 40 m | 46 m | 53 m | 61 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-bit | 1-ביט |
|---|---|---|---|
| 1 ק"מ | 217 × 368 | 39 KB | 10 KB |
| 3 קמ״ש | 648 × 1,102 | 349 KB | 87 KB |
| 5 ק"מ | 1,079 × 1,835 | 967 KB | 242 KB |
| 10 ק"מ | 2,157 × 3,669 | 3.8 MB | 967 KB |
| 20 ק״מ | 4,313 × 7,337 | 15.1 MB | 3.8 MB |
| 30 km | 6,469 × 11,005 | 33.9 MB | 8.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-bit, פסי גובה | 1-ביט, עץ או לא | ||||
|---|---|---|---|---|---|---|
| גולמי | zlib | lzma | גולמי | zlib | lzma | |
| 1 ק"מ | 40 KB | 13 KB | 13 KB | 10 KB | 4 KB | 4 KB |
| 3 קמ״ש | 352 KB | 90 KB | 82 KB | 88 KB | 28 KB | 23 KB |
| 5 ק"מ | 967 KB | ~250 KB | ~230 KB | 242 KB | ~70 KB | ~60 KB |
| 10 ק"מ | 3.8 MB | 1.0 MB | 0.9 MB | 967 KB | 268 KB | 217 KB |
| 20 ק״מ | 15.1 MB | ~4 MB | ~3.6 MB | 3.8 MB | ~1 MB | ~0.85 MB |
| 30 km | 33.9 MB | ~9 MB | ~8 MB | 8.5 MB | ~2.4 MB | ~1.9 MB |
שתיים דברים מזיזים אלה. ככל שרחוק יותר מהקטבים, ריבוע צריך פחות עמודות, כך שהקבצים הגולמיים קטנים: ריבוע 30 ק"מ 4-bit בגובה 45°N הוא 28.5 MB מול 33.9 MB כאן. וייעור צפוף אפילו לא כל כך טוב כמו קרקע פתוחה: ריבוע 30 ק"מ אמיתי 4-bit בטווח האלפים הצרפתיים ליד Aix-les-Bains, בעיקר יער, הגיע ל-9.5 MB עם lzma, בערך שליש מהגודל הגולמי שלה, כאשר ריבועי Windermere ירדו לערך רבע. lzma תמיד הקטן ביותר, בערך עשירית עבור 4-ביט וחומש עבור 1-ביט.
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 בתים, endian קטן, ואז השורות, צפון ראשון.
| בתים | סוג | ערך |
|---|---|---|
| 0 | char[4] | ACTR |
| 4 | uint8 | גרסה, 1 |
| 5 | uint8 | Bitek cellaként, 1 vagy 4 |
| 6 | uint16 | תאים לכל תואר, 24000 |
| 8 | int32 | קצה צפוני בתאים: רוחב הגיאוגרפי שלו × 24000 |
| 12 | int32 | קצה מערבי בתאים: אורך הגיאוגרפי שלו × 24000 |
| 16 | uint32 | שורות |
| 20 | uint32 | עמודות |
| 24 | uint32 | בתים לכל שורה |
| 28 | uint32 | 0, vyhrazeno |
הקצוות הם מספרים שלמים של תאים, ולכן מיקום ממוקד לתא שלו בדיוק: שורה north_edge - 1 - floor(lat * 24000), עמודה floor(lon * 24000) - west_edge.
Przykłady
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, רחוב ציבורי, וה-decoder של ה-Jupiter של Altimeter Cloud. בחבילה באחת ישר לחיץ הסופי, החיץ הזה משמש כמילון, ולכן מעבר לקובץ עצמו הוא צריך רק כ-16 KB בזמן שהוא עובד. ב-ESP32, compress=zlib לא צריך כלום נוסף: miniz's tinfl כבר ב-ROM שלו. xz-embedded אינו זה להשתמש: הוא קורא .xz, לא .lzma.
בתוך ה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.
קרדיט AltimeterCloud
חינם לשימוש. אם אתה משתמש 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”. כל קרדיטים שמקורות הנתונים שלעצמם מבקשים, מופעלים בעמוד זה, חלים גם כן.



















