Geospatial web apps are lacking fun animations. We're going to change that.
Most web maps are painfully static. Windy proved years ago that animating flow fields makes data instantly legible - and honestly just way more fun to look at. So I built animated wind and water layers into Sarkoa.
To animate wind or water, the map needs to know which way the flow is going at every spot. That grid of little arrows is called a vector field. A web map receives almost everything as tiles (small square images), so the arrows have to be hidden inside ordinary images: the browser gets a picture, reads the colour of each pixel, and turns the colour back into an arrow. Squeezing the arrows into colours is encoding, and getting them back out is decoding.
Slow-moving water is where my first encoder completely fell apart.
On a test flow field over the Ottawa River, a slow current (0.585 in model velocity units) came back pointing 2.08° off after encoding and decoding, and roughly 9% of the entire grid had direction errors bigger than 5°. Switching to a non-linear encoding brought that exact test vector down to 0.18° (Ottawa codec field summary).
Why slow flow gets bent sideways
Each arrow is stored as two numbers per pixel: how fast the flow is heading east (u) and how fast it is heading north (v). The direction is just the balance between the two. An image can only hold whole steps of colour, so each number gets rounded to the nearest step - the jargon is quantizing. When both numbers are big, rounding barely matters. When both are small, the rounding is a large share of each one, so it doesn’t just make the speed slightly wrong - it visibly bends the angle of the stream.
To keep tiles compact, I pack both u and v into one RGB tile at 12 bits each, which means 4,096 possible steps per number (red and green hold the high bits, blue holds the leftover low bits, and one value is reserved for nodata so missing pixels never look like calm water).
My first pass spaced those 4,096 steps evenly from the slowest value to the fastest, like a ruler with marks every centimetre. But one very fast cell at Chaudière Falls sets the top of the ruler, and almost all of the river is slow, so most of the water was crammed between the first few marks.
The fix was simple: take the square root of each number before rounding (keeping the sign), then square it back on decode. Square roots stretch out small numbers and squash big ones, so the ruler ends up with lots of fine marks near zero, where slow water lives, and coarse marks up where the falls are (headings measured from east):
| Vector | Speed in model units | Heading |
|---|---|---|
| Input | 0.5850 | −28.648° |
| Uniform encoding | 0.5637 | −26.565° |
| Square-root encoding | 0.5828 | −28.473° |
You can pull the input components and both decoded results directly.
Where it shows: wind has no pre-drawn paths

NOAA GFS surface wind analysis, 10 m above ground. These streamlines are drawn from a single saved model run after its eastward and northward components pass through the square-root tile encoder and decoder.
Sarkoa animates flow in two ways, and only one of them depends on this encoding.
On the NOAA GFS global wind map there are no lines stored anywhere. Every moving particle looks at the pixel under it, decodes u and v, and steps that way, many times a second. If the decoded direction is two degrees off, every particle crossing that pixel drifts two degrees off. That’s the layer the 12 bits matter for. Watch the live wind layer on Sarkoa.
The river map below is the other kind. Its paths were traced once, ahead of time, and saved as lines, and the particles just ride along them. It shows the same stretch of the Ottawa River the test vector came from, drawn the way that doesn’t need the encoder.
Amber paths come from the Ottawa, green from the Gatineau and pink from the Rideau. This is a simple 2D flow model without depth or mixing, so read the colours as where the water came from, not as a real-time dye trace. Inspect the confluences full screen.