Replies: 2 comments 2 replies
-
in developmentseed/titiler-stacapi#5 we've used an env variable for this |
Beta Was this translation helpful? Give feedback.
-
I understand the argumentation that alternate assets support is a subject for application-level logic, not core. I imagine that many applications will need this - but many perhaps not, too. VEDA Backend implemented a tiler for alternate assets called @attr.s
class PgSTACReaderAlt(PgSTACReader):
"""Custom STAC Reader for the alternate asset format used widely by NASA.
Only accept `pystac.Item` as input (while rio_tiler.io.STACReader accepts url or pystac.Item)
"""
def _get_asset_info(self, asset: str) -> AssetInfo:
"""Validate asset names and return asset's url.
Args:
asset (str): STAC asset name.
Returns:
str: STAC asset href.
"""
if asset not in self.assets:
raise InvalidAssetName(f"{asset} is not valid")
asset_info = self.input.assets[asset]
extras = asset_info.extra_fields
if ("alternate" not in extras) or ("s3" not in extras["alternate"]):
raise MissingAssets("No alternate asset found")
info = AssetInfo(url=extras["alternate"]["s3"]["href"], metadata=extras)
info["env"] = {}
if "file:header_size" in asset_info.extra_fields:
h = asset_info.extra_fields["file:header_size"]
info["env"].update({"GDAL_INGESTED_BYTES_AT_OPEN": h})
if requester_pays := extras["alternate"]["s3"].get("storage:requester_pays"):
if requester_pays:
info["env"].update({"AWS_REQUEST_PAYER": "requester"})
if bands := extras.get("raster:bands"):
stats = [
(b["statistics"]["minimum"], b["statistics"]["maximum"])
for b in bands
if {"minimum", "maximum"}.issubset(b.get("statistics", {}))
]
if len(stats) == len(bands):
info["dataset_statistics"] = stats
return info This alternative tiler is then exposed at a new endpoint on the same application: Just like if there was an additional parameter on the original I suggest we wait around to see whether this topic here gets upvotes from the community and only consider this further, if it does. |
Beta Was this translation helpful? Give feedback.
-
Some STAC catalogs keep links to cloud-readable assets (S3) in
assets > alternate > key > href
, rather than the mainasset > href
- i.e. using the Alternate Assets STAC extension.Could we consider adding a mechanism to TiTiler-PgSTAC to use these alternate asset hrefs?
Examples
https://landsatlook.usgs.gov/stac-server/collections/landsat-c2ard-sr/items/LC09_AK_001011_20240818_20240822_02_SR?.asset=asset-reduced_resolution_browse
https://pgstac.demo.cloudferro.com/collections/sentinel-2-l2a/items
Solution illustration
Just for illustration - from a user interface point of view, I am thinking of a parameter to pass to endpoints like
/collections/{collection_id}/items/{item_id}/tiles/{tileMatrixSetId}/{z}/{x}/{y}.{format}
like&alternate_assets_key=s3
or so.Btw, since we were facing collections like this for VEDA, we implemented a dedicated reader in veda-backend:
class PgSTACReaderAlt(PgSTACReader)
But seeing that the practice of alternate assets is more common, perhaps this would warrant a core feature?
Beta Was this translation helpful? Give feedback.
All reactions