Skip to content

Grid and tiles

imageserver_export.grid

The target raster: a grid whose edges sit on whole pixels.

Every tile of an export is a window of this grid, so its bounds are exact multiples of the resolution and the service never has to resample to fit the size asked for. Resampling a band that carries sentinels (255 "no data" next to 0-100 percentages) can invent valid values exactly where data is missing.

Grid dataclass

width x height pixels of res units, top-left at (left, top).

snap classmethod

snap(bounds: Bounds, *, res: float, crs: int) -> Grid

The smallest grid of res that contains bounds (in crs).

Edges grow outward to the next multiple of res: rounding would cut a strip off the area asked for.

from_lonlat classmethod

from_lonlat(bbox: Bounds, *, res: float, crs: int = 3035) -> Grid

The grid covering a longitude/latitude box, in crs (LAEA Europe by default).

The box is reprojected with densified edges, not by its four corners: in an equal-area projection the sides of a geographic box curve, and the southernmost point is not a corner. Measured on Italy, the corners alone cut 6.8 km off the southern edge (Lampedusa outside the raster).

imageserver_export.tiles

Cutting a grid into requests the service accepts.

Tile dataclass

A window of the target grid, in pixels.

bounds

bounds(grid: Grid) -> Bounds

The tile's box in the grid's CRS: whole pixels by construction.

plan

plan(grid: Grid, *, tile_px: int = DEFAULT_TILE_PX) -> list[Tile]

Tiles that cover the grid exactly once, edge tiles clamped to the grid.

occupied

occupied(tile: Tile, valid: ndarray, factor: int) -> bool

Whether a tile may hold data, judged on an overview factor times coarser.

valid marks the overview pixels that hold data. The tile's footprint on the overview is grown by one overview pixel on every side, so data sampled just across a tile edge still keeps the tile.