You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some STAC catalogs keep links to cloud-readable assets (S3) in assets > alternate > key > href, rather than the main asset > href - i.e. using the Alternate Assets STAC extension.
We considered adding a mechanism to TiTiler-PgSTAC to use these alternate asset hrefs, but the preferred solution was to implement this at the application level for now.
Since we were facing collections like this for VEDA, we implemented a dedicated reader in veda-backend: class PgSTACReaderAlt(PgSTACReader)
VEDA Backend implemented a tiler for alternate assets called s3 this way:
@attr.sclassPgSTACReaderAlt(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. """ifassetnotinself.assets:
raiseInvalidAssetName(f"{asset} is not valid")
asset_info=self.input.assets[asset]
extras=asset_info.extra_fieldsif ("alternate"notinextras) or ("s3"notinextras["alternate"]):
raiseMissingAssets("No alternate asset found")
info=AssetInfo(url=extras["alternate"]["s3"]["href"], metadata=extras)
info["env"] = {}
if"file:header_size"inasset_info.extra_fields:
h=asset_info.extra_fields["file:header_size"]
info["env"].update({"GDAL_INGESTED_BYTES_AT_OPEN": h})
ifrequester_pays:=extras["alternate"]["s3"].get("storage:requester_pays"):
ifrequester_pays:
info["env"].update({"AWS_REQUEST_PAYER": "requester"})
ifbands:=extras.get("raster:bands"):
stats= [
(b["statistics"]["minimum"], b["statistics"]["maximum"])
forbinbandsif {"minimum", "maximum"}.issubset(b.get("statistics", {}))
]
iflen(stats) ==len(bands):
info["dataset_statistics"] =statsreturninfo
This alternative tiler is then exposed at a new endpoint on the same application: /alt/collections/{collection_id}/items/{item_id}.
It is up to the user to basically use the right URL pattern for a specific collection.
The new base route /alt, as in /alt/collections, is non-invasive on the existing routes.
An alternative could be to add 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. Or not specify the key but a flag - since s3 seems to be a commonly used alternate asset key?
Acceptance criteria
The TiTiler tiles endpoints can pick up assets from alternate assets s3 instead of the main item href, for selected collections
Labels
enhancement
discussion
help wanted
The text was updated successfully, but these errors were encountered:
Description
Some STAC catalogs keep links to cloud-readable assets (S3) in assets > alternate > key > href, rather than the main asset > href - i.e. using the Alternate Assets STAC extension.
We considered adding a mechanism to TiTiler-PgSTAC to use these alternate asset hrefs, but the preferred solution was to implement this at the application level for now.
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
Possible solution
Since we were facing collections like this for VEDA, we implemented a dedicated reader in veda-backend:
class PgSTACReaderAlt(PgSTACReader)
VEDA Backend implemented a tiler for alternate assets called
s3
this way:This alternative tiler is then exposed at a new endpoint on the same application:
/alt/collections/{collection_id}/items/{item_id}
.It is up to the user to basically use the right URL pattern for a specific collection.
The new base route
/alt
, as in/alt/collections
, is non-invasive on the existing routes.An alternative could be to add 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. Or not specify the key but a flag - sinces3
seems to be a commonly used alternate asset key?Acceptance criteria
s3
instead of the main item href, for selected collectionsLabels
The text was updated successfully, but these errors were encountered: