Coarse cells¶
imageserver_export.aggregate ¶
From a fine raster to coarse cells: the mean and the share of valid pixels.
A 100 m imperviousness raster feeds a model on 1 km cells: each cell wants the mean of its 10x10 pixels, and how many of them were real data. Sentinel values (254 "unclassifiable", 255 "no data") must stay out of the mean, or a coastal cell half in the sea comes out 128 % sealed.
The raster is read one strip of cells at a time, so a whole country at 10 m never has to fit in memory.
Aggregate
dataclass
¶
Coarse cells on grid: mean (NaN with no valid pixel) and valid_fraction.
valid_fraction is over the whole cell: a cell that sticks out past the
raster's edge counts the missing part as not valid.
aggregate ¶
aggregate(path: Path, factor: int, *, valid_range: tuple[float, float] | None = None) -> Aggregate
Cells of factor x factor pixels of the GeoTIFF at path.
A pixel counts if it lies in valid_range; without it, if it is not the
file's nodata. The cell grid starts at the raster's top-left corner, so
for cells to fall on an existing grid (the 1 km EEA reference grid, say)
export on a grid snapped to it: Grid.snap(..., res=100) with bounds on
whole kilometres.