内陸水路API
アクセス & 制限Public, no key needed · Heavy▾
誰でも利用可能です。プロファイルからの無料APIキーは制限を引き上げます: X-API-Key ヘッダー、またはとして api_key= アドレスで。
| 5分 | 時間 | 日 | |
|---|---|---|---|
| キーなし | 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 and X-RateLimit-Reset制限を超えると、エラーになります 429 〜と retry_after 秒単位。拒否されたリクエストはカウントされません。
水が地点周辺の正方形を覆っている場合、およびその種類:約10メートルの各セルは、一般的な水(湖、貯水池、池、川、運河、沿岸の海)、小川、溝、排水路、または乾地として返されます。同じデータです。 内陸水マップ 描画します。web ページまたはスクリプト用の JSON として、または flight computer またはグラウンドステーションが搭載できる小さなバイナリファイルとして要求してください。これにより、launch サイトの water をその日に取得するのではなく、ファームウェアに組み込むことができます。
lat lon size_kmパラメータ
| パラメータ | 意味 |
|---|---|
lat, lon | 矩形の中央、10進度数 (lng 受け入れられます) |
size_km | 正方形の 1 辺の長さ(km 単位)。0 より大きく 30 まで。省略した場合は 1。10 km を超える正方形は format=bin のみ。 |
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)64 KBの辞書を使用、正確に Tree Canopy API それを与えます。 |
classes | オプション。保持するクラスのリスト(例: 1,2; every other class comes back as 0. Left out, all three. |
download | オプション。 1 ブラウザに保存させる format=bin ファイルとして回答し、正方形に名前を付けます。 |
The classes
| Class | What | From |
|---|---|---|
| 0 | Dry | |
| 1 | General water | ESA WorldCover's permanent water; OpenStreetMap's lakes, ponds, reservoirs, marina basins and river areas; rivers and canals mapped as lines; the sea along the coast |
| 2 | Streams and becks | OpenStreetMap waterway=stream |
| 3 | Ditches and drains | OpenStreetMap waterway=drain and ditch |
Any cell with water in it at all takes its class, however little: a stream a metre wide comes back as an unbroken line of cells. That is meant for hazard checks, where a cell with any water in it is a place something can land wet. Where two classes meet in a cell the worse is kept, 1 over 2 over 3, so a stream running into a lake is part of the lake. Many ditches and drains are dry for much of the year, and streams and drains that pass through culverts may show as open where they are not; classes=1,2 leaves ditches and drains out.
The satellite part gives the same quality worldwide; the OpenStreetMap part fills in what the satellite cannot see, such as shaded rivers, crowded marinas and anything narrower than a cell, but only has what has been mapped. The satellite water is as it stood in 2021.
The cells
The grid is the water store's own, so nothing is resampled: each cell is exactly 1/12000 of a degree each way, about 9.3 m north to south and, at UK latitudes, about 5.5 m east to west. 行0は北辺、列0は西辺です; rows run south and columns east. Each cell is 2 ビット、そのクラス, 行に沿って端から端まで配置されたセルで、最初のセルが最上位ビットに配置されます 4 つのセルが各バイトを満たします。すべての行は全バイトで始まるため、行 j バイト位置から開始 j * row_bytes.
Ground not yet in the database is 0 as well; the JSON answer's coverage_pct 正方形のどの程度がデータベースに保存されているかを示します, water_pct it is water of the classes kept, and の量はいくら class_pct 各クラスの金額。WorldCoverタイルを超えて海へと進む場合、水データは全くありません:開いた海は地形由来で、地面0m以下。
サイズ
英国緯度 (54°N) では、圧縮前に:
| 正方形 | セル | ファイル |
|---|---|---|
| 1 km | 108 × 186 | 5.0 KB |
| 3 km | 324 × 556 | 44 KB |
| 5 km | 540×926 | 122 KB |
| 10 km | 1,078 × 1,850 | 487 KB |
| 20 km | 2,156 × 3,700 | 1.9 MB |
| 30 km | 3,234 × 5,550 | 4.3 MB |
ほとんどの地面は乾いているため、圧縮によってこれらは長い距離を移動します。いくつかの湖と小川が含まれている正方形は通常、生のサイズのごく一部に圧縮されます。 lzma 最も小さいです。
バイナリファイル
以下 format=bin: a 32 byte header, little endian, then the rows, north first. It is the same layout as the tree canopy and roads files, so one reader handles all three; only the name, the version and the bits a cell differ.
| バイト | タイプ | 値 |
|---|---|---|
| 0 | char[4] | ACWT |
| 4 | uint8 | バージョン、2 |
| 5 | uint8 | ビット/セル、2 |
| 6 | uint16 | 1度あたりのセル数、12000 |
| 8 | int32 | 北端(セル単位):その緯度 × 12000 |
| 12 | int32 | 西端(セル): 経度 × 12000 |
| 16 | uint32 | 行 |
| 20 | uint32 | 列 |
| 24 | uint32 | 行ごとのバイト数 |
| 28 | uint32 | 0、予約済み |
辺はセル全体の数字なので、位置はそのセルに正確にマップされます: 行 north_edge - 1 - floor(lat * 12000), 列 floor(lon * 12000) - west_edge.
例
https://www.altimetercloud.com/api/water/?lat=54.35&lon=-2.95&size_km=3
https://www.altimetercloud.com/api/water/?lat=54.35&lon=-2.95&size_km=5&classes=1,2&format=bin&compress=zlib
https://www.altimetercloud.com/api/water/?lat=54.35&lon=-2.95&size_km=10&format=bin&compress=lzma&download=1
JSONの答え
{
"success": true,
"lat", "lon", "size_km", "bits", bits is 2
"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",
"water_pct", cells with water of the classes kept
"class_pct": { "1": ..., "2": ... }, each class kept
"classes": { "1": "general water", ... },
"kept": [1, 2, 3], the classes asked for
"coverage_pct", cells the database holds
"meaning", "order", "compress", "bytes",
"data_b64", the rows, row 0 first, compressed if asked
"file_name", "seconds",
"credits": { "water", "source", "doi", "licence", "full" }
}
Reading the cells
On a device: what water is below me
Give a position and get the class of the cell it is in. 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.
// C
typedef struct __attribute__((packed)) {
char magic[4]; // "ACWT" (roads "ACRD", trees "ACTR")
uint8_t version; // 2
uint8_t bits; // 2
uint16_t cells_per_deg; // 12000
int32_t north_edge; // latitude of the north edge * 12000
int32_t west_edge; // longitude of the west edge * 12000
uint32_t rows, cols, row_bytes, reserved;
} GridHeader;
// the class at a position, 0 to 3, or -1 outside the square
int waterClassAt(const GridHeader *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;
uint8_t b = cells[(uint32_t)j * h->row_bytes + (i >> 2)];
return (b >> (6 - 2 * (i & 3))) & 3; // four cells a byte, first in the top bits
}
近くの水
着陸時に、セルサイズからメートル単位で測定した半径内に中心がある細胞を歩きます: 111320 / 12000 北から南への m、緯度の余弦を西から東に乗じたもの。円内で最悪のクラス、水である細胞の割合、各クラスまでの最小距離はすべて 1 パスから来ています。
double ch = 111320.0 / h->cells_per_deg, cw = ch * cos(lat * M_PI / 180.0);
int ny = (int)(radius_m / ch) + 1, nx = (int)(radius_m / cw) + 1, wet = 0, all = 0;
double nearest[4] = { -1, -1, -1, -1 }; // by class
for (int dy = -ny; dy <= ny; dy++)
for (int dx = -nx; dx <= nx; dx++) {
double d = sqrt((dx * cw) * (dx * cw) + (dy * ch) * (dy * ch));
if (d > radius_m) continue;
int c = waterClassAt(h, cells, lat + dy / (double)h->cells_per_deg, lon + dx / (double)h->cells_per_deg);
if (c < 0) continue;
all++;
if (c) { wet++; if (nearest[c] < 0 || d < nearest[c]) nearest[c] = d; }
}
マイクロコントローラ上でアンパック
The compression is the same as the tree canopy files': compress=lzma で展開します LzmaDecode() LZMA SDKから、およびESP32上 compress=zlib 追加は不要です。miniz の tinfl はROMに入っています。参照 マイクロコントローラ上でアンパック Tree Canopyページにあります。
コンピューター上
# Python
import requests, struct, zlib, numpy as np
r = requests.get('https://www.altimetercloud.com/api/water/',
params={'lat': 54.35, 'lon': -2.95, '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])
b = np.unpackbits(np.frombuffer(f[32:], np.uint8).reshape(rows, rb), axis=1)[:, :cols * 2]
water = (b[:, 0::2] << 1) | b[:, 1::2] # rows x cols, 0 dry, 1 water, 2 stream, 3 ditch
lat_of_row = lambda j: (north - j - 0.5) / cpd
lon_of_col = lambda i: (west + i + 0.5) / cpd
エラー
エラーは JSON として返されます "success": false, コードとメッセージ。
| コード | 意味 |
|---|---|
412 | A parameter is missing or not valid, the square is more than 30 km, JSON was asked for over 10 km, or classes= is not a list of 1 to 3 |
413 | 正方形のセルが多すぎます。これは極に非常に近い場合のみ発生します |
429 | アドレスからのリクエストが多すぎるか、まだ処理中です |
501 | 要求された圧縮は今のところ利用できません |
試してみる
ザ Inland Water Map has a download panel: move the map so the cross sits on your launch site, choose the size and compression, and it saves the file from this API.
Water data credits
© ESA WorldCover project 2021 / Contains modified Copernicus Sentinel data (2021) processed by ESA WorldCover consortium. ESA WorldCover 10 m 2021 v200, Zanaga, D. et al. 2022, doi:10.5281/zenodo.7254221, licensed under CC BY 4.0.
Contains OpenStreetMap data © OpenStreetMap contributors, available under the Open Database Licence (ODbL).
The two are combined here and reduced to a water class a cell, which changes them: this is not the original data of either.
Licence of this data. Because it contains OpenStreetMap data, the data this API gives out is made available under the Open Database License (ODbL) 1.0. You may use it freely, commercially too, as long as you credit it as above and share any database you make from it under the same licence.
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”. このページにリストされている、データ自体のソースが要求するいかなるクレジットも同様に適用されます。



















