Skip to content

Mosaic writer

imageserver_export.mosaic

Writing tiles into one GeoTIFF that exists only when it is whole.

Mosaic

A tiled, compressed GeoTIFF on grid, written to <path>.part.

Used as a context manager: on a clean exit the .part is renamed to path; on an exception it is deleted. A half-written raster that a later reader takes for a whole one is worse than no raster.

tags are written as GeoTIFF metadata when the mosaic is whole, together with valid_px: where the pixels came from travels with them.

paste

paste(tile: Tile, image: bytes) -> int

Write one tile into its window; the number of valid pixels in it.

A tile whose size differs from the one asked for raises: pasting it would shift the data by however many pixels the service got wrong.

fill

fill(tile: Tile) -> None

Write nodata into a tile's window: a tile known to hold no data.

valid_mask

valid_mask(band: ndarray, *, valid_range: tuple[float, float] | None, nodata: float | None) -> np.ndarray

Which pixels hold data: inside valid_range, else not nodata, else all.

read_band

read_band(image: bytes) -> np.ndarray

The first band of a GeoTIFF held in memory.