내륙 수역 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 그리고 X-RateLimit-Reset제한을 초과하면 오류 응답 429 포함 retry_after 초 단위입니다. 거부된 요청은 계산되지 않습니다.

GET 키가 필요 없음 JSON 또는 바이너리 파일 최대 30 km² 2비트 클래스 시간당 주소당 60개 요청

물이 한 점 주위의 정사각형 범위를 넘어서는 곳과 어떤 종류인지: 약 10미터 범위의 각 셀은 일반 수역(호수, 저수지, 연못, 강, 운하 및 해안을 따라가는 바다), 개울 또는 소류지, 도랑 또는 배수로 또는 건조한 지역으로 반환되며, 동일한 데이터입니다. 내륙 수로 지도 그림을 그립니다. 웹 페이지나 스크립트용 JSON으로 요청하거나, flight computer나 지상국이 휴대할 수 있는 작은 바이너리 파일로 요청하면, 발사장의 물을 당일에 가져올 필요 없이 펌웨어에 내장할 수 있습니다.

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

매개변수

파라미터의미
lat, lon정사각형의 중앙, 십진도 (lng 도 허용됨)
size_km제곱형의 한 변의 거리(km), 0 이상 30 이하. 생략하면 1. 10 km를 초과하는 사각형은 다음과 같이 표시됩니다 format=bin 만 해당.
format선택 사항. json (기본값, 10km까지의 사각형): 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 2비트, 그것의 클래스, 행을 따라 끝에서 끝으로 배치된 셀과 첫 번째 셀이 최상위 비트에 있으므로 4개의 셀이 각 바이트를 채웁니다. 모든 행은 전체 바이트에서 시작되므로 행 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 타일 너머 바다에서는 수심 데이터가 전혀 없습니다: 외해는 지형에서 나오며, 지면은 0m 이하입니다.

크기

영국 위도(54°N)에서 압축 전:

정사각형셀파일
1 km108 × 1865.0 KB
3 km324 × 55644 KB
5 km540 × 926122 KB
10 km1,078 × 1,850487 KB
20 km2,156 × 3,7001.9 MB
30 km3,234 × 5,5504.3 MB

대부분의 지면은 건조하므로 압축으로 인해 이들이 많이 줄어듭니다. 몇 개의 호수와 개울이 있는 정사각형은 보통 원본 크기의 작은 부분으로 압축되며, lzma 가장 작습니다.

binary file

함께 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.

예시

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이고 위도의 코사인에 동서를 곱합니다. 원에서 가장 나쁜 클래스(물인 셀의 비율)와 각 클래스까지의 최소 거리는 모두 한 번의 패스에서 나옵니다.

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의 추가 사항이 필요하지 않습니다. tinfl ROM에 있습니다. 보기 마이크로컨트롤러에서 압축 풀기 나무 캐노피 페이지에서.

컴퓨터에서

# 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요청한 압축이 현재 사용 불가능합니다

시도해 보세요

그 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”. 이 페이지에 나열된 데이터의 출처가 요청하는 모든 출처 표시가 적용됩니다.