You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prefer the point APIs (`value`, `forecast`) when you only need scalars. They handle variable lookup, time resolution, and missing-data NaN-filling in one call. The tile API is for map renderers that need full raster pixels per tile.
51
42
52
-
### Batched tile fetch
43
+
### Point snapshot: `wmt.value()`
53
44
54
-
For UIs that paint several tiles in one frame, `tiles()` issues 1–2 coalesced
55
-
range requests instead of one per tile (when all tiles share the same
56
-
variable + time block):
45
+
Many variables at one point at one time. Useful for map-click tooltips showing "temperature + wind + precip right here, right now":
57
46
58
47
```ts
59
-
const frame =awaitt2m.tiles({
60
-
time: 12,
61
-
coords: [
62
-
{ z: 5, x: 16, y: 11 },
63
-
{ z: 5, x: 17, y: 11 },
64
-
{ z: 5, x: 18, y: 11 },
65
-
],
48
+
const snap =awaitwmt.value({
49
+
lat: 52.52,
50
+
lon: 13.405,
51
+
time: 0, // step index or Date
52
+
variables: ["dbzh", "temperature_2m"],
66
53
});
67
-
// frame[i] is always a Float32Array (NaN-filled if missing/out-of-range).
68
-
```
69
54
70
-
You can tune coalescing with the `coalesce` option:
snap.values.dbzh; // number, NaN if missing/NoData
57
+
snap.values.temperature_2m;
74
58
```
75
59
76
-
### Forecast / time-series at a point
60
+
### Point time-series: `wmt.forecast()`
77
61
78
-
Sample one or more variables at a (lat, lon) point across the whole time axis:
62
+
Many variables at one point across the time axis:
79
63
80
64
```ts
81
65
const fc =awaitwmt.forecast({
@@ -84,9 +68,9 @@ const fc = await wmt.forecast({
84
68
variables: ["dbzh", "temperature_2m"],
85
69
});
86
70
87
-
fc.times; // Date[] — one per step, aligned with all series
88
-
fc.values.dbzh; // Float32Array — fc.values.dbzh[i] is at fc.times[i]
89
-
fc.values.dbzh[0]; // NaN if missing/NoData
71
+
fc.times; // Date[], one per step, aligned with all series
72
+
fc.values.dbzh; // Float32Array; fc.values.dbzh[i] is at fc.times[i]
73
+
fc.values.dbzh[0]; // NaN if missing/NoData
90
74
```
91
75
92
76
Optional `z` (defaults to `maxZoom`) and `timeRange` to restrict the window:
@@ -104,9 +88,55 @@ await wmt.forecast({
104
88
});
105
89
```
106
90
107
-
`forecast()` fans out one parallel request per `(variable, time step)` — there is
108
-
no cross-step coalescing, because different time steps live in different blocks.
109
-
Units for each series stay on the variable handle (`wmt.variable("dbzh").unit`).
91
+
`forecast()` fans out one parallel request per `(variable, time step)`. There is no cross-step coalescing, because different time steps live in different blocks. For per-variable metadata (`unit`, `colormap`, `range`) reach for the variable handle: `wmt.variable("dbzh").unit`.
92
+
93
+
### Tile rendering for maps
94
+
95
+
Map renderers need the actual raster pixels of a tile, not point samples. Resolve a `Variable` handle once and reuse it for every tile in every frame:
96
+
97
+
```ts
98
+
const t2m =wmt.variable("temperature_2m");
99
+
100
+
t2m.unit; // "K"
101
+
t2m.range; // { min, max }, feed into your colormap
102
+
t2m.colormap; // "magma"
103
+
104
+
// Fetch one tile (Float32Array of tileSize² values; NaN where NoData).
// Or by absolute time, must match a step exactly.
108
+
const pixels2 =awaitt2m.tile({
109
+
time: newDate("2026-05-06T12:00:00Z"),
110
+
z: 5, x: 16, y: 11,
111
+
});
112
+
```
113
+
114
+
For UIs that paint several tiles in one frame, `tiles()` coalesces 1 or 2 range requests instead of one per tile (when all tiles share the same variable + time block):
115
+
116
+
```ts
117
+
const frame =awaitt2m.tiles({
118
+
time: 12,
119
+
coords: [
120
+
{ z: 5, x: 16, y: 11 },
121
+
{ z: 5, x: 17, y: 11 },
122
+
{ z: 5, x: 18, y: 11 },
123
+
],
124
+
});
125
+
// frame[i] is always a Float32Array (NaN-filled if missing/out-of-range).
0 commit comments