Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update raster API for alternate assets extension #157

Open
1 task
anayeaye opened this issue Mar 8, 2023 · 1 comment
Open
1 task

Update raster API for alternate assets extension #157

anayeaye opened this issue Mar 8, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@anayeaye
Copy link
Collaborator

anayeaye commented Mar 8, 2023

What

Update raster/titiler API to accommodate items that use the alternate assets extension (a common standard used in NASA EarthdataCloud datasets).

Notes

extension docs: stac-extension/alternate-assets

Alternate assets examples
https://landsatlook.usgs.gov/stac-server/collections/landsat-c2l2-sr/items/LE

Detail of a single asset with a login protected https href and an alternate s3 url
alternate-assets-detail
07_L2SR_005113_20010116_20200917_02_T2_SR

template/explanation as code:
Here are some notes from @vincentsarago about how we can fetch nested alternate asset urls by building a TilerFactory using a custom STACReader

import attr
from rio_tiler.io import stac
from rio_tiler.types import AssetInfo
from rio_tiler.errors import InvalidAssetName

@attr.s
class STACReader(stac.STACReader)

    @minzoom.default
    def _minzoom(self):
        return self.tms.minzoom

    @maxzoom.default
    def _maxzoom(self):
        return self.tms.maxzoom
    
    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.item.assets[asset]
        info = AssetInfo(url=asset_info.extra_fields["alternate"]["s3"]["href"])

        if "file:header_size" in asset_info.extra_fields:
            h = asset_info.extra_fields["file:header_size"]
            info["env"] = {"GDAL_INGESTED_BYTES_AT_OPEN": h}

        return info

AC

  • raster-api stac and mosaic endpoints will render data for selected items with standard asset hrefs and items that use the alternate assets extension
@anayeaye anayeaye added the enhancement New feature or request label Mar 8, 2023
@j08lue j08lue changed the title [WIP] Update raster API for alternate assets extension Update raster API for alternate assets extension Sep 29, 2023
@moradology moradology self-assigned this Jan 24, 2024
@moradology
Copy link
Contributor

OK, so I've got this issue pretty well cornered, but there are a couple questions that remain.

  1. First one of the non-trivial properties on the alt asset from the example is 'requester-pays'. Any ideas on this question? Conditional requester-pays developmentseed/titiler#758

  2. Are there any alternate assets that we might want to support other than 's3'? If so, we'll want to make the path slightly more complex (or else add an appropriate query parameter).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants