rio_tiler.mosaic.reader
rio_tiler.mosaic.reader ¶
rio_tiler.mosaic: create tile from multiple assets.
mosaic_point_reader ¶
mosaic_point_reader(mosaic_assets: Sequence, reader: Callable[..., PointData], *args: Any, pixel_selection: Union[Type[MosaicMethodBase], MosaicMethodBase] = FirstMethod, chunk_size: Optional[int] = None, threads: int = MAX_THREADS, allowed_exceptions: Tuple = (PointOutsideBounds), **kwargs) -> Tuple[PointData, List]
Merge multiple assets.
Args:
mosaic_assets (sequence): List of assets.
reader (callable): Reader function. The function MUST take `(asset, *args, **kwargs)` as arguments, and MUST return a PointData object.
args (Any): Argument to forward to the reader function.
pixel_selection (MosaicMethod, optional): Instance of MosaicMethodBase class. Defaults to `rio_tiler.mosaic.methods.defaults.FirstMethod`.
chunk_size (int, optional): Control the number of asset to process per loop.
threads (int, optional): Number of threads to use. If <= 1, runs single threaded without an event loop. By default reads from the MAX_THREADS environment variable, and if not found defaults to multiprocessing.cpu_count() * 5.
allowed_exceptions (tuple, optional): List of exceptions which will be ignored. Note: `PointOutsideBounds` is likely to be raised and should be included in the allowed_exceptions. Defaults to `(TileOutsideBounds, )`.
kwargs (optional): Reader callable's keywords options.
Returns:
Examples:
>>> def reader(asset: str, *args, **kwargs) -> PointData:
with Reader(asset) as src:
return src.point(*args, **kwargs)
pt = mosaic_point_reader(["cog.tif", "cog2.tif"], reader, 0, 0)
mosaic_reader ¶
mosaic_reader(mosaic_assets: Sequence, reader: Callable[..., ImageData], *args: Any, pixel_selection: Union[Type[MosaicMethodBase], MosaicMethodBase] = FirstMethod, chunk_size: Optional[int] = None, threads: int = MAX_THREADS, allowed_exceptions: Tuple = (TileOutsideBounds), **kwargs) -> Tuple[ImageData, List]
Merge multiple assets.
Args:
mosaic_assets (sequence): List of assets.
reader (callable): Reader function. The function MUST take `(asset, *args, **kwargs)` as arguments, and MUST return an ImageData.
args (Any): Argument to forward to the reader function.
pixel_selection (MosaicMethod, optional): Instance of MosaicMethodBase class. Defaults to `rio_tiler.mosaic.methods.defaults.FirstMethod`.
chunk_size (int, optional): Control the number of asset to process per loop.
threads (int, optional): Number of threads to use. If <= 1, runs single threaded without an event loop. By default reads from the MAX_THREADS environment variable, and if not found defaults to multiprocessing.cpu_count() * 5.
allowed_exceptions (tuple, optional): List of exceptions which will be ignored. Note: `TileOutsideBounds` is likely to be raised and should be included in the allowed_exceptions. Defaults to `(TileOutsideBounds, )`.
kwargs (optional): Reader callable's keywords options.
Returns:
Examples:
>>> def reader(asset: str, *args, **kwargs) -> ImageData:
with Reader(asset) as src:
return src.tile(*args, **kwargs)
x, y, z = 10, 10, 4
img = mosaic_reader(["cog.tif", "cog2.tif"], reader, x, y, z)
>>> def reader(asset: str, *args, **kwargs) -> ImageData:
with Reader(asset) as src:
return src.preview(*args, **kwargs)
img = mosaic_reader(["cog.tif", "cog2.tif"], reader)