Skip to content

surface asset_expression in MultiBaseTilerFactory (STAC) #367

Closed
@vincentsarago

Description

https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/io/base.py#L458-L460

For this we'll need to update

# Dependencies for MultiBaseReader (e.g STACReader)
@dataclass
class AssetsBidxParams(DefaultDependency):
"""Asset and Band indexes parameters."""
assets: Optional[str] = Query(
..., title="Asset indexes", description="comma (',') delimited asset names.",
)
bidx: Optional[str] = Query(
None, title="Band indexes", description="comma (',') delimited band indexes",
)
def __post_init__(self):
"""Post Init."""
if self.assets is not None:
self.kwargs["assets"] = self.assets.split(",")
if self.bidx is not None:
self.kwargs["indexes"] = tuple(
int(s) for s in re.findall(r"\d+", self.bidx)
)
@dataclass
class AssetsBidxExprParams(DefaultDependency):
"""Assets, Band Indexes and Expression parameters."""
assets: Optional[str] = Query(
None, title="Asset indexes", description="comma (',') delimited asset names.",
)
expression: Optional[str] = Query(
None,
title="Band Math expression",
description="rio-tiler's band math expression (e.g B1/B2)",
)
bidx: Optional[str] = Query(
None, title="Band indexes", description="comma (',') delimited band indexes",
)
def __post_init__(self):
"""Post Init."""
if not self.assets and not self.expression:
raise MissingAssets(
"assets must be defined either via expression or assets options."
)
if self.assets is not None:
self.kwargs["assets"] = self.assets.split(",")
if self.expression is not None:
self.kwargs["expression"] = self.expression
if self.bidx is not None:
self.kwargs["indexes"] = tuple(
int(s) for s in re.findall(r"\d+", self.bidx)
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions