On this page
Spatial Data Pipeline
Six original readings record the brightness of trail lights. Each row has an east coordinate, a north coordinate and a brightness reading. The Flow rotates coordinates a quarter turn counterclockwise, groups readings into four-metre cells and prints each cell’s sample count and mean brightness.
php examples/spatial-data-pipeline.php
A point at (-1, 3) moves to (-3, -1). The transformed point falls in cell (-1, -1) because floor rounds negative values down. Truncating toward zero would put it in the cell on the opposite side of the origin.
The cell summary keeps the sample count alongside the mean. Retain the original observations whenever you need to repeat the aggregation with a different cell size or origin.
Open the PHP source. Original example for Darkwood Code Calendar 2026 edition 03.