Skip to content

rio_tiler.expression

rio_tiler.expression

rio-tiler.expression: Parse and Apply expression.

apply_expression

apply_expression(blocks: Sequence[str], bands: Sequence[str], data: ndarray) -> MaskedArray

Apply rio-tiler expression.

Args:

blocks (sequence): expression for a specific layer.
bands (sequence): bands names.
data (numpy.array):  array of bands.

Returns:

get_expression_blocks

get_expression_blocks(expression: str) -> List[str]

Split expression in blocks.

Parameters:

  • expression (str) –

    band math/combination expression.

Returns:

  • list ( List[str] ) –

    expression blocks (str).

Examples:

>>> parse_expression("b1/b2,b2+b1")
    ("b1/b2", "b2+b1")

parse_expression

parse_expression(expression: str, cast: bool = True) -> Tuple

Parse rio-tiler band math expression.

Parameters:

  • expression (str) –

    band math/combination expression.

  • cast (bool, default: True ) –

    cast band names to integers (convert to index values). Defaults to True.

Returns:

  • tuple ( Tuple ) –

    band names/indexes.

Examples:

>>> parse_expression("b1;b2")
    (2, 1)
>>> parse_expression("B1/B2", cast=False)
    ("2", "1")