Skip to content

virtualize

lazymerge.virtualize

default_virtualizer

default_virtualizer(
    registry: Any,
    target_resolution: float | None = None,
    max_overviews: int = 6,
) -> Callable[[str, SourceEntry, Any, list[str]], None]

Create a virtualizer callback that uses VirtualTIFF to create virtual zarr references.

The callback virtualizes COG assets into an Icechunk store using VirtualiZarr, then writes zarr conventions (spatial, proj, multiscales) so that merge() can discover and read the virtualized arrays.

When target_resolution is provided, the callback automatically selects the single best COG overview level for that resolution (assuming a standard 2x pyramid) and only virtualizes level 0 plus that overview. This avoids virtualizing overview levels that will never be read.

Parameters:

  • registry (Any) –

    An ObjectStoreRegistry for resolving COG URLs to object stores.

  • target_resolution (float | None, default: None ) –

    The target pixel size passed to merge(). When set, only the best overview for this resolution is virtualized (along with level 0). When None, only level 0 is virtualized.

  • max_overviews (int, default: 6 ) –

    Maximum overview IFD index to consider. Ignored when target_resolution is None.

Returns:

  • Callable

    A callback compatible with merge(virtualize=...).