Skip to content

rio_tiler.io.stac

rio_tiler.io.stac

rio_tiler.io.stac: STAC reader.

STACReader

Bases: MultiBaseReader

STAC Reader.

Attributes:

  • input (str) –

    STAC Item path, URL or S3 URL.

  • item ((dict or Item, STAC)) –

    Stac Item.

  • tms (TileMatrixSet) –

    TileMatrixSet grid definition. Defaults to WebMercatorQuad.

  • minzoom (int) –

    Set minzoom for the tiles.

  • maxzoom (int) –

    Set maxzoom for the tiles.

  • include_assets (set of string) –

    Only Include specific assets.

  • exclude_assets (set of string) –

    Exclude specific assets.

  • include_asset_types (set of string) –

    Only include some assets base on their type.

  • exclude_asset_types (set of string) –

    Exclude some assets base on their type.

  • default_assets (list of string) –

    Default assets to use if none are defined.

  • reader (BaseReader) –

    rio-tiler Reader. Defaults to rio_tiler.io.Reader.

  • reader_options (dict) –

    Additional option to forward to the Reader. Defaults to {}.

  • fetch_options (dict) –

    Options to pass to rio_tiler.io.stac.fetch function fetching the STAC Items. Defaults to {}.

Examples:

>>> with STACReader(stac_path) as stac:
    stac.tile(...)
>>> with STACReader(stac_path, reader=MyCustomReader, reader_options={...}) as stac:
    stac.tile(...)
>>> my_stac = {
        "type": "Feature",
        "stac_version": "1.0.0",
        ...
    }
    with STACReader(None, item=my_stac) as stac:
        # the dict will be translated to a pystac item
        assert isinstance(stac.item, pystac.Item)
        stac.tile(...)

__attrs_post_init__

__attrs_post_init__()

Fetch STAC Item and get list of valid assets.

_get_asset_info

_get_asset_info(asset: str) -> AssetInfo

Validate asset names and return asset's info.

Parameters:

  • asset (str) –

    STAC asset name.

Returns:

  • AssetInfo ( AssetInfo ) –

    STAC asset info.

_get_reader

_get_reader(asset_info: AssetInfo) -> Tuple[Type[BaseReader], Dict]

Get Asset Reader.

get_asset_list

get_asset_list() -> List[str]

Get valid asset list

_get_assets

_get_assets(stac_item: Item, include: Optional[Set[str]] = None, exclude: Optional[Set[str]] = None, include_asset_types: Optional[Set[str]] = None, exclude_asset_types: Optional[Set[str]] = None) -> Iterator

Get valid asset list.

Parameters:

  • stac_item (Item) –

    STAC Item.

  • include (Optional[Set[str]], default: None ) –

    Only Include specific assets.

  • exclude (Optional[Set[str]], default: None ) –

    Exclude specific assets.

  • include_asset_types (Optional[Set[str]], default: None ) –

    Only include some assets base on their type.

  • exclude_asset_types (Optional[Set[str]], default: None ) –

    Exclude some assets base on their type.

Yields str: valid STAC asset name.

_to_pystac_item

_to_pystac_item(item: Union[None, Dict, Item]) -> Union[None, Item]

Attr converter to convert to Dict to pystac.Item

Parameters:

Returns pystac.Item: pystac STAC item object.

aws_get_object

aws_get_object(bucket: str, key: str, request_pays: bool = False, client: client = None) -> bytes

AWS s3 get object content.

fetch

fetch(filepath: str, **kwargs: Any) -> Dict

Fetch STAC items.

A LRU cache is set on top of this function.

Parameters:

  • filepath (str) –

    STAC item URL.

  • kwargs (any, default: {} ) –

    additional options to pass to client.

Returns:

  • dict ( Dict ) –

    STAC Item content.