Tree Canopy API
Accesso e limitiPublic, no key needed · Heavy▾
Aperto a tutti. Una chiave API gratuita dal tuo profilo aumenta i limiti: inviarla in un X-API-Key intestazione, o come api_key= nell'indirizzo.
| 5 minuti | Ora | Giorno | |
|---|---|---|---|
| Senza una chiave | 20 | 120 | 500 |
| Con una chiave | 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.
Accedi per creare una chiave gratuita nella pagina del tuo profilo.
Ogni risposta contiene X-RateLimit-Remaining e X-RateLimit-Reset. Se supera un limite, la risposta è errore 429 con retry_after in secondi. Le richieste rifiutate non vengono conteggiate.
Dove sono gli alberi e quanto sono alti, in un quadrato intorno a un punto: ogni cella dell'archivio di canopia, circa 3 per 5 metri, gli stessi dati di Mappa altezza chioma alberi disegni. Richiedili come JSON per una pagina web o uno script, o come un piccolo file binario che un computer di volo o una stazione di terra può trasportare e leggere con poche righe di codice, in modo che gli alberi del sito di lancio possano essere integrati nel firmware anziché recuperati il giorno stesso.
lat lon size_kmParametri
| Parametro | Significato |
|---|---|
lat, lon | Il centro del quadrato, gradi decimali (lng anche accettato) |
size_km | Il lato del quadrato in km, più di 0 e fino a 30. Se omesso, 1. I quadrati superiori a 10 km arrivano come format=bin solo, e impiegano più tempo per essere preparati: fino a mezzo minuto per 30 km. |
bits | Facoltativo. 4 (predefinito): ogni cella è la sua fascia altimetrica, 0 a 15. 1: ogni cella è 1 per alberi di 3 m o più e 0 per nessuno, un quarto della dimensione. |
format | Facoltativo. json (il valore predefinito, per quadrati fino a 10 km): le celle come base64 all'interno di una risposta JSON con tutto il necessario per leggerle. bin: un'intestazione di 32 byte e le celle, come file, per qualsiasi dimensione. |
compress | Facoltativo. none (l'impostazione predefinita), zlib oppure lzma. Con format=bin the whole file is compressed; with json le celle sono, prima della base64. lzma è LZMA-solo (.lzma), progettato per dispositivi piccoli: vedi LZMA di seguito. |
download | Facoltativo. 1 fa salvare un file al browser da format=bin risposta come file, denominato per il quadrato. |
Le celle

Un quadrato di 1 km vicino a Windermere: a sinistra come mostrato dalla Mappa dell'altezza della chioma arborea, a destra disegnato direttamente da un download a 4 bit, ogni cella colorata per la sua banda e nera dove non ci sono alberi.
La griglia è propria del negozio di baldacchini, quindi nulla viene ricampionato: ogni cella è esattamente 1/24000 di grado in ogni direzione, circa 4,6 m da nord a sud e, alle latitudini del Regno Unito, circa 2,7 m da est a ovest. La riga 0 è il bordo nord e la colonna 0 il bordo ovest; rows run south and columns east. Every row starts on a whole byte, so row j inizia al byte j * row_bytes.
bits | Per cella | Imballaggio |
|---|---|---|
4 | Banda di altezza 0 a 15 | Due celle un byte, la prima nei quattro bit alti |
1 | 1 = alberi di 3 m o più, 0 = nessuno | Otto celle un byte, la prima nel bit più alto |
Le bande di altitudine, altitudine minima in ciascuna:
| Banda | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Da | nessuno | 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 |
Le altezze sono gli alberi come si presentavano quando è stata scattata l'immagine satellitare: tra il 2017 e il 2020, principalmente dal 2018 al 2020 per i metadati, e 2020 per il riempimento ETH. I boschi abbattuti o piantati da allora non verranno ancora visualizzati.
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 conta quelle celle.
Dimensioni
Alle latitudini del Regno Unito, prima della compressione:
| Quadrato | Celle | 4-bit | 1 bit |
|---|---|---|---|
| 1 km | 217 × 368 | 39 KB | 10 KB |
| 3 km | 648 × 1.102 | 349 KB | 87 KB |
| 5 km | 1.079 × 1.835 | 967 KB | 242 KB |
| 10 km | 2.157 × 3.669 | 3,8 MB | 967 KB |
| 20 km | 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:
| Quadrato | 4-bit, bande di altezza | 1 bit, albero o no | ||||
|---|---|---|---|---|---|---|
| Grezzo | zlib | lzma | Grezzo | zlib | lzma | |
| 1 km | 40 KB | 13 KB | 13 KB | 10 KB | 4 KB | 4 KB |
| 3 km | 352 KB | 90 KB | 82 KB | 88 KB | 28 KB | 23 KB |
| 5 km | 967 KB | ~250 KB | ~230 KB | 242 KB | ~70 KB | ~60 KB |
| 10 km | 3,8 MB | 1,0 MB | 0,9 MB | 967 KB | 268 KB | 217 KB |
| 20 km | 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 |
Due cose muovono questi. Più lontano dai poli un quadrato ha bisogno di meno colonne, quindi i file grezzi si riducono: un quadrato 4-bit di 30 km a 45°N è 28,5 MB contro 33,9 MB qui. E le foreste fitte si compattano meno bene del terreno aperto: un vero quadrato 4-bit di 30 km nelle Alpi francesi vicino ad Aix-les-Bains, per lo più boscoso, arrivava a 9,5 MB con lzma, circa un terzo della sua dimensione grezza, dove i quadrati di Windermere sono scesi a circa un quarto. lzma è sempre il più piccolo, di circa un decimo per 4-bit e un quinto per 1-bit.
LZMA
compress=lzma fornisce un flusso LZMA-alone, il .lzma formato, non .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 sa esattamente quanto aspettarsi. Su un computer, xz --format=lzma -d o di Python lzma modulo con FORMAT_ALONE la estrae.
Il file binario
Con format=bin: un header di 32 byte, little endian, quindi le righe, nord prima.
| Byte | Tipo | Valore |
|---|---|---|
| 0 | char[4] | ACTR |
| 4 | uint8 | Versione 1 |
| 5 | uint8 | Bit per cella, 1 o 4 |
| 6 | uint16 | Celle per grado, 24000 |
| 8 | int32 | Margine settentrionale nelle celle: sua latitudine × 24000 |
| 12 | int32 | Bordo ovest in celle: la sua longitudine × 24000 |
| 16 | uint32 | Righe |
| 20 | uint32 | Colonne |
| 24 | uint32 | Byte per riga |
| 28 | uint32 | 0, riservato |
I bordi sono numeri interi di celle, quindi una posizione corrisponde esattamente alla sua cella: riga north_edge - 1 - floor(lat * 24000), colonna floor(lon * 24000) - west_edge.
Esempi
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
La risposta 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;
}
Alberi vicino a me
Per l'atterraggio: ogni cella il cui centro è entro un raggio dalla posizione, quante alberi sostiene, quanto dista il più vicino e il più alto tra loro. La versione completa è treesWithin() in the reader download below; it works in metres from the cell size, which is 111320 / 24000 m da nord a sud e quel valore per il coseno della latitudine da ovest a est.
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
Alberi e il terreno
Le altezze qui sono le altezze degli alberi sopra il terreno su cui si trovano, non sopra il livello del mare o sopra il tuo launch pad. Quindi il file ti dice che ci sono alberi sotto di te e quanto sono alti, ma non a che distanza sotto di te si trovano i loro vertici: su una valle o un pendio, dipende dal terreno quanto dagli alberi. Per questo, combinalo con le altezze del terreno dal Elevazione del terreno API, o il Griglia del terreno 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
Decompressione su un microcontroller
A compress=lzma il file si estrae con LzmaDecode() da LZMA SDK di Igor Pavlov: due file C, LzmaDec.c e LzmaDec.h, dominio pubblico, e il decoder che Altimeter Cloud Jupiter contiene. Decompresso in un'unica soluzione direttamente nel buffer finale, quel buffer funge da dizionario, quindi oltre al file stesso ha bisogno solo di circa 16 KB mentre funziona. Su un ESP32, compress=zlib non ha bisogno di nulla di extra: miniz's tinfl è già nella sua ROM. xz-embedded non è quello da usare: legge .xz, non .lzma.
Nel file zip: tree_reader.h e tree_reader.c con tutto quanto sopra più treeUnpackLzma(), e i file del decoder LZMA SDK con cui è costruito Jupiter. Per Arduino, copiali nella cartella dello sketch e aggiungi #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 Pagina LZMA SDK.
Su un computer
# 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
Errori
Gli errori tornano come JSON con "success": false, un codice e un messaggio.
| Codice | Significato |
|---|---|
412 | Un parametro è mancante o non valido, il quadrato è più grande di 30 km, o JSON è stato richiesto per più di 10 km |
413 | Il quadrato ha troppo poche celle, il che accade solo molto vicino ai poli |
429 | Troppi richieste dal tuo indirizzo, o una ancora in elaborazione |
501 | La compressione richiesta non è disponibile al momento |
Prova
Il Mappa altezza chioma alberi ha un pannello di download: sposta la mappa in modo che la croce sia sul tuo sito di lancio, scegli le dimensioni, le celle e la compressione, e salva il file da questa 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.
Crediti ad AltimeterCloud
Gratuito. Se usi this API, or anything made from the answers, in a commercial product or service, credit AltimeterCloud with a link to www.altimetercloud.com nel punto di utilizzo: sullo schermo, pagina o stampa dove appaiono i dati, ad esempio “Data from AltimeterCloud.com”. Tutti i crediti che le fonti dei dati richiedono, elencati su questa pagina, si applicano anche.



















