树冠 API

访问与限制Public, no key needed · Heavy▾

对所有人开放。来自您的个人资料的免费 API 密钥可提高限制:将其发送到 X-API-Key header, or as 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公里方形 1 位或 4 位单元格 每个地址每小时60个请求

树木所在的位置以及高度,围绕一个点的正方形:canopy store 的每个单元格,大约 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 km 最多需要半分钟。
bits可选。 4 (默认值):每个单元格是其高度带,0 至 15。 1: 每个单元格:3 米或以上的树为 1,没有树为 0,大小为四分之一。
format可选。 json (默认值,适用于最大10 km的正方形):单元格作为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 以命名的文件形式回答。

单元格

Een 1 km vierkant dicht bij Windermere op de Tree Canopy Height Map, naast hetzelfde vierkant dat rechtstreeks uit de 4-bits download is getekend

温德米尔湖附近的 1 平方公里:左侧显示树冠高度图,右侧直接从其 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

高度是卫星影像拍摄时树木的高度:Meta 数据为 2017 年至 2020 年(主要为 2018 年至 2020 年),ETH 填充数据为 2020 年。自那以后砍伐或种植的森林尚不会显示。

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 公里217 × 36839 KB10 KB
3 公里648 × 1,102349 KB87 KB
5 km1,079 × 1,835967 KB242 KB
10 km2,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位,高度波段1 位、树或非树
原始zliblzma原始zliblzma
1 公里40 KB13 KB13 KB10 KB4 KB4 KB
3 公里352 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 公里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

有两个因素改变这些。离极点越远,正方形需要的列数越少,因此原始文件缩小:45°N 处的 30 km 4 位正方形是 28.5 MB,而这里是 33.9 MB。密集的森林比开放地面压缩性差:法国阿尔卑斯山靠近艾克斯莱班的真实 30 km 4 位正方形,大部分是森林,使用 lzma, 约其原始大小的三分之一,温德米尔平方下降到约四分之一。 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 的 lzma 模块与 FORMAT_ALONE 将其解包。

二进制文件

带有 format=bin: 32 字节标头、小端序,然后按行排列,北端优先。

字节类型值
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,或 Terrain Grid 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 KB。在 ESP32 上, compress=zlib 不需要任何额外内容:miniz 的 tinfl 已在其ROM中。 xz-embedded 不是要使用的:它读取 .xz, 否 .lzma.

Tree reader and LZMA decoderzip,打包 26/09/2026

在zip中: tree_reader.h 和 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,或在 10 km 以上请求了 JSON
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”。此页面上列出的数据自身来源要求的任何署名也适用。