Replies: 1 comment
-
Hi @Duke74
Yes, but this takes customization because you'll need a titiler/src/titiler/mosaic/titiler/mosaic/factory.py Lines 83 to 87 in 72a8df9 to be of type something like 👇 from typing import Type
import attr
from fastapi import FastAPI
from rio_tiler.io import MultiBandReader, BaseReader, Reader
from rio_tiler.errors import InvalidBandName
from titiler.mosaic.factory import MosaicTilerFactory
app = FastAPI(openapi_url="/api", docs_url="/api.html",)
@attr.s
class customReader(MultiBandReader):
reader: Type[BaseReader] = attr.ib(default=Reader, init=False)
def __attrs_post_init__(self):
"""Fetch Reference band to get the bounds."""
self.bands = [f"b{ix + 1}" for ix in range(len(self.input))]
# We set the bands to be loaded by default to be all the bands
self.default_bands = [f"b{ix + 1}" for ix in range(len(self.input))]
with self.reader(self.input[0], tms=self.tms, **self.reader_options) as cog:
self.bounds = cog.bounds
self.crs = cog.crs
self.minzoom = cog.minzoom
self.maxzoom = cog.maxzoom
def _get_band_url(self, band: str) -> str:
"""Validate band's name and return band's url."""
if band not in self.bands:
raise InvalidBandName(f"{band} is not valid")
index = self.bands.index(band)
return self.input[index]
mosaic = MosaicTilerFactory(dataset_reader=customReader, router_prefix="/mosaicjson")
app.include_router(
mosaic.router,
prefix="/mosaicjson",
tags=["MosaicJSON"],
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Thanks for this awesome project, it's really helpfull.
I've been doing some tests with sentinel2 data lately and the tiler is working great with a mosaicJSON file that link directly to cog files like this :
Now rather than using the TCI sentinel files I would like to work with the different cogs available for each items exemple here:
https://radiantearth.github.io/stac-browser/#/external/earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_32TLR_20241104_0_L2A
Like for exemple merging the red, green ,blue from the different single band cogs available, rather than using the TCI file
But my issue is I'm not sure how to do it. The mosaicJSON spec doesn't seems to make it possible to have multiple files for multiple bands for a same tile.
Can mosaicJSON link directly to the STAC items ?
But then what parameters to use when requesting the tiles ?
Thanks for the help !
Beta Was this translation helpful? Give feedback.
All reactions