API למים פנימיים

גישה והגבלותPublic, no key needed · Heavy▾

פתוח לכולם. מפתח API חינמי מהפרופיל שלך מגביל את הגבולות: שלח אותו ב- X-API-Key כותרת, או כ api_key= בכתובת.

5 דקותHourיום
ללא מפתח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 קמ"ר מחלקות 2-ביט 60 בקשות לשעה לכל כתובת

כאשר המים נמצאים על ריבוע סביב נקודה, ומה סוגם: כל תא של בערך 10 מטרים חוזר כמים כלליים (אגמים, מאגרים, בריכות, נהרות, תעלות והים לאורך החוף), זרם או נחל, תעלה או ניקוז, או יבש, אותם נתונים כמו מפת מים יבשתיים שרטוטים. בקש עבורו כ-JSON עבור דף אינטרנט או סקריפט, או כקובץ בינארי קטן שמחשב טיסה או תחנת קרקע יכול להיות, כך שמים של אתר השקה יכולים להיבנות בתוך firmware ולא להיות מביאים ביום.

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

פרמטרים

פרמטרמשמעות
lat, lonאמצע הריבוע, מעלות עשרוניות (lng מקובל גם)
size_kmהצלע של הריבוע בקילומטרים, יותר מ-0 ועד 30. אם הושמט, 1. ריבועים מעל 10 ק"מ מגיעים כ 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 מ׳ או מתחתיו.

גדלים

בקווי הרוחב של בריטניה (54°N), לפני דחיסה:

מרובעתאיםקובץ
1 ק"מ108 × 1865.0 KB
3 קמ״ש324 × 55644 KB
5 ק"מ540 × 926122 KB
10 ק"מ1,078 × 1,850487 KB
20 ק״מ2,156 × 3,7001.9 MB
30 km3,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
12int32Zachodnia krawędź w komórkach: jej długość geograficzna × 12000
16uint32שורות
20uint32עמודות
24uint32בתים לכל שורה
28uint320, vyhrazeno

הקצוות הם מספרים שלמים של תאים, ולכן מיקום ממוקד לתא שלו בדיוק: שורה 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הדחיסה המבוקשת אינה זמינה כעת

נסה זאת

ה- 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”. כל קרדיטים שמקורות הנתונים שלעצמם מבקשים, מופעלים בעמוד זה, חלים גם כן.