Списък на инструментите

Inland Water API

Достъп и лимитиPublic, no key needed · Heavy▾

Отворен за всички. Безплатен API ключ от твоя профил увеличава лимитите: изпрати го в X-API-Key заглавка, или като api_key= w adresie.

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 v sekundách. Odmítnuté požadavky se nezapočítávají.

GET Не е необходим ключ JSON или двоичен файл До 30 км квадрат Класове 2-бит 60 заявки в час на адрес

Където водата е над квадрат около точка и какъв вид: всяка клетка от около 10 метра се връща като обща вода (езера, резервоари, пулове, реки, канали и море по бреговата линия), поток или ручей, дренажна канавка или осушаване, или суха, същите данни като Вътрешна карта на водата чертаи. Поискайте го като JSON за уеб страница или скрипт, или като малък двоичен файл, който летателен компютър или наземна станция могат да носят, така че водата на стартирането да може да бъде вградена във фърмуер, вместо да се извлича в деня.

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

Параметри

ПараметърЗначение
lat, lonСерединта на квадрата, десетични градуса (lng също приет)
size_kmСтраната на квадрата в км, повече от 0 и до 30. Ако е пропусната, 1. Squares over 10 km come as format=bin само.
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) с 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

ClassWhatFrom
0Dry
1General waterESA 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
2Streams and becksOpenStreetMap waterway=stream
3Ditches and drainsOpenStreetMap 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 два бита, неговия клас, клетките разпоредени край до край по реда с първата клетка в най-високите битове, така че четири клетки запълват всеки байтВсеки ред започва на цял байт, така че ред j започва при байт j * row_bytes.

Ground not yet in the database is 0 as well; the JSON answer's coverage_pct показва колко от квадрата съхранява базата данни, water_pct колко от това е вода на класовете запазени, и class_pct колко струва всеки клас. На морето, отвъд плочките на WorldCover, няма никакви водни данни: откритото море идва от терена, земя при или под 0 m.

Размери

На британските географски ширини (54°N), преди компресиране:

КвадратКлеткиФайл
1 км108 × 1865.0 KB
3 км324 × 55644 KB
5 км540 × 926122 KB
10 km1,078 × 1,850487 KB
20 км2 156 × 3 7001,9 MB
30 км3,234 × 5,5504.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.

БайтТипСтойност
0char[4]ACWT
4uint8Версия, 2
5uint8Бита на клетка, 2
6uint16Клетки на степен, 12000
8int32Северен край в клетки: неговата географска ширина × 12000
12int32Западен край в клетки: неговата дължина × 12000
16uint32Редове
20uint32Колони
24uint32Байтове на ред
28uint320, запазено

Краищата са цели числа клетки, така че позиция се съответства на нейната клетка точно: ред north_edge - 1 - floor(lat * 12000), колона floor(lon * 12000) - west_edge.

Przykłady

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 м север на юг и това пъти косинуса на географската ширина запад на изток. Най-лошия класс в кръга, делът на клетките, които са вода, и най-малкото разстояние до всеки клас идват от един проход.

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; }
  }

Разпаковане на микроконтролер

Компресията е същата като при файловете на балдахина на дърветата: compress=lzma разпакетиране с LzmaDecode() от LZMA SDK и на ESP32 compress=zlib не се нуждае от нищо допълнително, като miniz's 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, код и съобщение.

КодЗначение
412A 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Поискането на компресия не е налично точно сега

Опитайте го

The 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”. Всички благодарности, които собствените източници на данните изискват, наредени на тази страница, също се прилагат.