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 and X-RateLimit-Reset制限を超えると、エラーになります 429 〜と retry_after 秒単位。拒否されたリクエストはカウントされません。

GET キーは不要 JSON またはバイナリ ファイル 最大30km四方 1 ビットまたは 4 ビット セル 1時間あたりアドレスあたり60リクエスト

木がある場所、および高さ、ポイント周辺の正方形上:キャノピーストアの各セル、約3×5メートル、同じデータ 樹冠高マップ 描画。ウェブページまたはスクリプト用の JSON として、またはフライトコンピュータまたはグラウンドステーションが数行のコードで読み込める小さなバイナリファイルとして要求してください。これで、打ち上げサイトのツリーを当日に取得するのではなく、ファームウェアに組み込むことができます。

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

パラメータ

パラメータ意味
lat, lon矩形の中央、10進度数 (lng 受け入れられます)
size_km正方形の 1 辺の長さ(km 単位)。0 より大きく 30 まで。省略した場合は 1。10 km を超える正方形は format=bin のみで、準備に時間がかかります: 30 km で最大 30 秒。
bitsオプション。 4 (デフォルト):各セルはその高度バンド、0~15。 1: 各セルは3 m以上の樹木で1、なしで0です。4分の1のサイズ。
formatオプション。 json (デフォルト、10 kmまでの正方形の場合):JSON答え内のセルをbase64として読む必要なすべてを含めてください。 bin: 32 バイトのヘッダーとセルを、任意のサイズのファイルとして。
compressオプション。 none (デフォルト), zlib または lzma. format=bin the whole file is compressed; with json セルは base64 の前にあります。 lzma はLZMA単体(.lzma」、小型デバイス用に設計: 参照 LZMA 以下。
downloadオプション。 1 ブラウザに保存させる format=bin ファイルとして回答し、正方形に名前を付けます。

セル

Windermereの近くの1 km四角形、Tree Canopy Height Mapで、4ビットダウンロードから直接描画された同じ四角形の横

Windermereの近くの1 kmの正方形:左側はTree Canopy Height Mapに示されたとおり、右側は4ビットダウンロードから直接描画され、各セルはそのバンドで着色され、木がない場合は黒。

グリッドはキャノピーストア独自のものであり、リサンプリングは行われません:各セルは正確に1/24000度で、南北方向に約4.6m、イギリスの緯度では東西方向に約2.7mです。 行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 m以上の樹木、0 = なし8ビット:最初のセルが最上位ビット

各高さバンド、最低高度:

バンド0123456789101112131415
からなし3 m5 m7 m10 m13 m16 m19 m22 m26 m30 m35 m40 m46 m53 m61 m

高さは衛星画像が撮影された時点での樹木です:2017年から2020年の間、主に2018年から2020年はメタデータ、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ビット
1 km217 × 36839 KB10 KB
3 km648 × 1,102349 KB87 KB
5 km1,079 × 1,835967 KB242 KB
10 km2,157 × 3,6693.8 MB967 KB
20 km4,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ビット、高さバンド1ビット、木あるいは否
ローzliblzmaローzliblzma
1 km40 KB13 KB13 KB10 KB4 KB4 KB
3 km352 KB90 KB82 KB88 KB28 KB23 KB
5 km967 KB~250 KB~230 KB242 KB~70 KB~60 KB
10 km3.8 MB1.0 MB0.9 MB967 KB268 KB217 KB
20 km15.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

これら2つのものが影響します。極から遠いほど四角形は列が少なくて済むため、生ファイルが縮小されます。45°Nの30 km 4ビット四角形は28.5 MBで、ここは33.9 MBです。密集した林地は開放地より圧縮効率が悪くなります。フランスアルプスのエクス=レ=バンの近くの実際の30 km 4ビット四角形は、ほとんどが森林で9.5 MBでした。 lzma, 約3分の1の生サイズ。Windermere squaresは約4分の1まで低下しました。 lzma は常に最小です、4ビットで約10分の1、1ビットで約5分の1。

LZMA

compress=lzma LZMA単独ストリームを提供します。 .lzma format, not .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 knows exactly how much to expect. On a computer, xz --format=lzma -d またはPythonの lzma モジュール付き FORMAT_ALONE それをアンパック。

バイナリファイル

以下 format=bin: 32 バイトのヘッダー、リトルエンディアン、次に行、北が最初。

バイトタイプ値
0char[4]ACTR
4uint8Version, 1
5uint81セルあたりのビット数、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による:2つのCファイル, LzmaDec.c and LzmaDec.h, public domain、および Altimeter Cloud Jupiter が搭載する decoder。最終バッファに一度にアンパックされ、そのバッファが辞書として機能するため、ファイル自体を超えて約 16 KB のみが必要です。ESP32 上で, compress=zlib 特別なものは必要ありません:minizの tinfl 既にそのROMに含まれています。 xz-embeddedは使用するものではありません:読み込みが .xz, ではない .lzma.

ツリーリーダーとLZMAデコーダーzip、26/09/2026 にパック

ジップ内: tree_reader.h and tree_reader.c 上記のすべてに加えて treeUnpackLzma(), およびJupiterが構築されたLZMA SDKデコーダーファイル。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 km を超えています。または JSON が 10 km を超えて要求されました。
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”. このページにリストされている、データ自体のソースが要求するいかなるクレジットも同様に適用されます。