raster-expr
Per-pixel raster expressions, compiled to GPU shaders for client-side visualization.
This package is the Python client of raster-expr. It is a binding to the Rust crate raster-expr-core, so Python builds the same program types that the browser compiles.
Build an expression, and write its program to bytes:
import raster_expr as rx
nir = rx.input("nir")
red = rx.input("red")
program = rx.Program(nir + red + 1.0)
data = program.serialize()
The line that builds an expression that is not valid raises the error. For example, nir + True raises a TypeError, because a bool is not a number here.
This version has one kind of input, a float32 plane over the tile, so an input needs only its name. A later version declares more for an input: its storage data type, its axes, its nodata value and its mask. dev-docs/specs/2026-11-20_inputs-as-arrays.md has that design.
This version has two operators: addition (a + b) and negation (-a). The API is provisional.