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:
-
MaskedArray–numpy.array: output data.
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:
>>> get_expression_blocks("b1/b2;b2+b1")
['b1/b2', 'b2+b1']
parse_expression ¶
parse_expression(expression: str, cast: bool = True) -> tuple
Parse rio-tiler band math expression and extract bands.
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")
(1, 2)
>>> parse_expression("B1/B2", cast=False)
('1', '2')