इनलैंड वाटर API
Access & limitsPublic, no key needed · Heavy▾
सभी के लिए खुला। आपकी प्रोफाइल से एक निःशुल्क API कुंजी सीमा बढ़ाती है: इसे भेजें X-API-Key शीर्ष लेख, या जैसा api_key= पते में।
| 5 मिनट | घंटा | दिन | |
|---|---|---|---|
| एक key के बिना | 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.
एक मुफ़्त key बनाने के लिए अपने profile page में log in करें।
हर उत्तर ले जाता है X-RateLimit-Remaining और X-RateLimit-Reset. सीमा से अधिक, उत्तर त्रुटि है 429 के साथ retry_after सेकंड में। अस्वीकृत अनुरोध गिनती नहीं करते हैं।
जहाँ पानी एक बिंदु के चारों ओर एक वर्ग में है, और किस प्रकार का है: लगभग 10 मीटर के प्रत्येक सेल सामान्य पानी (झीलें, जलाशय, तालाब, नदियाँ, नहरें और समुद्र तट के साथ समुद्र), एक धारा या बेक, एक खाई या नाली, या सूखे के रूप में आता है, वही डेटा अंतर्देशीय जल मानचित्र draws। इसे web पेज या स्क्रिप्ट के लिए JSON के रूप में, या एक छोटी binary फ़ाइल के रूप में मांगें जो flight computer या ground station ले सकता है, ताकि launch site का पानी firmware में बनाया जा सके न कि दिन पर fetch किया जाए।
lat lon size_kmपैरामीटर
| पैरामीटर | अर्थ |
|---|---|
lat, lon | वर्ग के बीच में, दशमलव डिग्री (lng also accepted) |
size_km | किमी में वर्ग की भुजा, 0 से अधिक और 30 तक। छोड़ा गया, 1। 10 किमी से अधिक वर्ग के रूप में आते हैं format=bin केवल। |
format | वैकल्पिक। json (डिफ़ॉल्ट, 10 किमी तक के वर्गों के लिए): JSON उत्तर के अंदर सेल आधार 64 में उन्हें पढ़ने के लिए आवश्यक सब कुछ के साथ। bin: एक 32 बाइट हेडर और कक्ष, एक फ़ाइल के रूप में, किसी भी आकार के लिए। |
compress | वैकल्पिक। none (डिफ़ॉल्ट), zlib या lzma. साथ format=bin the whole file is compressed; with json कोशिकाएं, base64 से पहले। lzma LZMA-alone है (.lzma) with a 64 KB dictionary, exactly as the 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 दो बिट्स, इसकी क्लास, सेल को पंक्ति के साथ अंत से अंत तक रखा गया है सर्वोच्च बिट्स में पहला सेल, चार सेल प्रत्येक बाइट भरते हैं. हर पंक्ति एक पूरे बाइट पर शुरू होती है, इसलिए पंक्ति 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 tiles के बाहर, कोई जल डेटा नहीं है: खुली समुद्र इलाके से आती है, जमीन 0 मीटर पर या उससे नीचे।
आकार
यूके अक्षांशों पर (54°N), संपीड़न से पहले:
| वर्ग | Cells | फ़ाइल |
|---|---|---|
| 1 किमी | 108 × 186 | 5.0 KB |
| 3 km | 324 × 556 | 44 KB |
| 5 किमी | 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 |
अधिकांश जमीन सूखी है, इसलिए compression इन्हें बहुत नीचे ले जाता है: कुछ झीलों और धाराओं वाला एक वर्ग आमतौर पर अपने कच्चे आकार के एक छोटे से अंश तक संपीड़ित होता है, और 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.
| Byte | टाइप | मान |
|---|---|---|
| 0 | char[4] | ACWT |
| 4 | uint8 | Version, 2 |
| 5 | uint8 | बिट्स प्रति सेल, 2 |
| 6 | uint16 | डिग्री प्रति सेल, 12000 |
| 8 | int32 | उत्तरी किनारा कक्षों में: इसका अक्षांश × 12000 |
| 12 | int32 | पश्चिम की सीमा सेल में: इसकी देशांतर × 12000 |
| 16 | uint32 | पंक्तियां |
| 20 | uint32 | कॉलम |
| 24 | uint32 | Bytes per row |
| 28 | uint32 | 0, आरक्षित |
किनारे पूरी संख्या में कोशिकाएं हैं, इसलिए एक स्थिति अपनी कोशिका से बिल्कुल मेल खाती है: पंक्ति north_edge - 1 - floor(lat * 12000), column 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; }
}
माइक्रोकंट्रोलर पर अनपैक करना
compression tree canopy files के समान है: compress=lzma के साथ अनपैक करता है LzmaDecode() LZMA SDK से, और एक ESP32 पर compress=zlib needs nothing extra, as 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, एक कोड और एक संदेश।
| Code | अर्थ |
|---|---|
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 | वर्ग में बहुत सारे cells हैं, जो केवल poles के बहुत पास ही होता है |
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 को credit देना
उपयोग करने के लिए मुफ्त। यदि आप 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”. इस पृष्ठ पर सूचीबद्ध डेटा के अपने स्रोतों के लिए कोई भी क्रेडिट लागू होता है।



















