Tree Canopy API

גישה והגבלותPublic, no key needed · Heavy▾

פתוח לכולם. מפתח API חינמי מהפרופיל שלך מגביל את הגבולות: שלח אותו ב- X-API-Key כותרת, או כ api_key= בכתובת.

5 דקותHourיום
ללא מפתח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 קמ"ר תאים 1-bit או 4-bit 60 בקשות לשעה לכל כתובת

איפה העצים, וכמה גבוהים, על פני ריבוע סביב נקודה: כל תא של חנות הכיפה, בערך 3 על 5 מטר, אותם נתונים ה מפת גובה כתר העץ שרטוטים. בקש עבורו ב-JSON לעמוד ویב או סקריפט, או כקובץ בינארי קטן שמחשב טיסה או תחנת קרקע יכול להוביל ולקרוא בכמה שורות קוד, כך שיערות באתר הפתילה יכול להיבנות בתוך firmware ולא להיאסף ביום.

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 על מפת Tree Canopy Height, לצד אותו ריבוע המצויר ישירות מההורדה שלו בן 4 ביטים

ריבוע 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שני תאים בתים, הראשון בארבע ביטים גבוהים
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-bit1-ביט
1 ק"מ217 × 36839 KB10 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 km6,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-bit, פסי גובה1-ביט, עץ או לא
גולמיzliblzmaגולמיzliblzma
1 ק"מ40 KB13 KB13 KB10 KB4 KB4 KB
3 קמ״ש352 KB90 KB82 KB88 KB28 KB23 KB
5 ק"מ967 KB~250 KB~230 KB242 KB~70 KB~60 KB
10 ק"מ3.8 MB1.0 MB0.9 MB967 KB268 KB217 KB
20 ק״מ15.1 MB~4 MB~3.6 MB3.8 MB~1 MB~0.85 MB
30 km33.9 MB~9 MB~8 MB8.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 קטן, ואז השורות, צפון ראשון.

בתיםסוגערך
0char[4]ACTR
4uint8גרסה, 1
5uint8Bitek cellaként, 1 vagy 4
6uint16תאים לכל תואר, 24000
8int32קצה צפוני בתאים: רוחב הגיאוגרפי שלו × 24000
12int32קצה מערבי בתאים: אורך הגיאוגרפי שלו × 24000
16uint32שורות
20uint32עמודות
24uint32בתים לכל שורה
28uint320, 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.

קורא עץ ומפענח 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.

קרדיט 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”. כל קרדיטים שמקורות הנתונים שלעצמם מבקשים, מופעלים בעמוד זה, חלים גם כן.