Compose remote-sensing pipelines like you compose functions. Sentinel-2 to cloud-free NDVI in a handful of small operators, with the same code shape as your unit tests.
Where it comes from¶
Remote-sensing code tends to grow into long functions that mix band indexing, nodata handling, rescaling and georeferencing. Nothing in them can be reused or tested alone.
geotoolz cuts each step into an Operator: a typed callable with a
keyword-only constructor. It takes a geoarray.GeoArray (or a plain
ndarray) and returns the same kind of carrier on the same CRS and
transform, with band names and a fill value that match the output.
Chain operators with | into a Sequential, or wire them into a named
Graph when the pipeline branches. Both are operators too, so pipelines
nest, and get_config() turns any pipeline into JSON. The composition
core comes from pipekit; about
275 remote-sensing operators sit on top. How geotoolz meets the other
packages is on How the packages interlock.

Install¶
Until the first PyPI release, install from a clone (see the stack install); after it:
pip install geotoolz # every operator family
pip install geotoolz-ops # the slim base: kernels on NumPy, SciPy, pandas
pip install 'geotoolz-ops[raster,vector,morph,sensors]' # what geotoolz installs
pip install 'geotoolz-ops[patch]' # + tile → operate → stitch with geopatcherThe base install costs NumPy, SciPy, pandas, pyproj and affine: indices,
radiometry arithmetic, masks and normalisation run on it. GDAL, the vector
stack, scikit-image and georeader are extras. Operators that need an extra
import without it and raise an ImportError naming the extra when called.
| Extra | Pulls in | Needed for |
|---|---|---|
raster | rasterio | io file reads and writes, geom windows and resampling, patch_ops windows |
vector | geopandas, shapely | vector outputs and inputs: feature detections, mask polygons, measure contours, plume geometry |
morph | scikit-image | segment, feature, measure, connected components and skeletons, geom registration, the resampling behind geom.Resize / Resample |
sensors | georeader (which brings rasterio, geopandas, shapely) | the engine behind geom.Reproject / ReprojectLike / Mosaic / Vectorize / Resize / Resample (which also need morph), viz.AnnotatePolygons, io.LoadFromEE, io reads, mask rasterising, radiometry solar geometry |
viz | matplotlib | viz.ApplyColormap (named matplotlib colormaps) |
learn | scikit-learn, joblib | learn.SklearnOp / Pixelwise* imputer NaN strategies and save_state / load_state / state_path=; plume DBSCAN clump counting |
zarr | zarr>=3 | io.WriteZarr |
cloud | geotoolz-cloud | io.WriteCOG (validated COGs, local or to a bucket) |
hdf5 | geotoolz-cloud with h5py | io.ReadHDF on HDF5, local or remote |
hdf4 | geotoolz-cloud with pyhdf | io.ReadHDF on HDF4 |
netcdf | geotoolz-cloud with netCDF4 | io.ReadNetCDF |
vector-cube | xvec (+ xarray) | geom.coregister.RasterToPoints / PointsToRaster, bilinear point sampling |
hydra | hydra-zen | YAML builds() / instantiate() round-trips |
patch | geotoolz-patcher[pipekit] | geoops.patch_ops (tile → map → stitch, label-aware samplers) |
all | every extra above | everything |
Quickstart¶
Cloud-free NDVI from a Sentinel-2 L2A scene, first as a chain, then as a
graph that masks clouds with the SCL band. The scene here is synthetic: 12
reflectance bands plus SCL on a real UTM grid, named through
attrs["band_names"] as the geoproducts readers and geocatalog loaders do.
import numpy as np
from geoarray import GeoArray
from rasterio.transform import from_origin
import geoops as gz
L2A: list[str] = ["B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B8A", "B9", "B11", "B12"]
rng: np.random.Generator = np.random.default_rng(0)
dn: np.ndarray = rng.integers(200, 4000, size=(12, 64, 64), dtype=np.uint16) # (12, 64, 64) uint16
scl: np.ndarray = rng.choice([4, 5, 8, 9], size=(1, 64, 64)).astype(np.uint16) # (1, 64, 64) uint16 · 8, 9 = cloud
scene: GeoArray = GeoArray(
np.concatenate([dn, scl]), # (13, 64, 64) uint16
transform=from_origin(750_000, 4_350_000, 10, 10), # 10 m pixels
crs="EPSG:32610", # UTM zone 10N
fill_value=0,
attrs={"band_names": [*L2A, "SCL"]},
)
# Sequential — a linear chain, built with |
ndvi_pipeline: gz.Sequential = (
gz.SelectBands(bands=L2A) # (13, 64, 64) uint16 → (12, 64, 64) uint16
| gz.DNToReflectance(scale=1e-4) # (12, 64, 64) uint16 → (12, 64, 64) float64
| gz.NDVI(red="B4", nir="B8") # (12, 64, 64) float64 → (64, 64) float64
)
ndvi: GeoArray = ndvi_pipeline(scene) # (13, 64, 64) uint16 → (64, 64) float64 · NaN = no data
config: dict = ndvi_pipeline.get_config() # {"operators": [{"class": "SelectBands", "config": {...}}, ...]}
# Graph — the same steps, plus a cloud mask on a second branch
x: gz.Input = gz.Input("scene")
reflectance: gz.Node = gz.DNToReflectance(scale=1e-4)(gz.SelectBands(bands=L2A)(x)) # (12, 64, 64) float64
ndvi_node: gz.Node = gz.NDVI(red="B4", nir="B8")(reflectance) # (64, 64) float64
cloud: gz.Node = gz.S2SCL(targets=["cloud_shadow", "cloud", "cirrus"])(x) # (64, 64) bool · True = drop
clean: gz.Node = gz.ApplyMask()(ndvi_node, cloud) # (64, 64) float64 · NaN under cloud
graph: gz.Graph = gz.Graph(inputs={"scene": x}, outputs={"ndvi": clean, "cloud": cloud})
out: dict[str, GeoArray] = graph(scene=scene) # {"ndvi": (64, 64) float64, "cloud": (64, 64) bool}
assert out["ndvi"].grid == scene.gridBoth results keep the scene’s CRS and transform. NDVI declares NaN as
its fill because it is a new float quantity; the mask uses False.
Is this the right tool?¶
| You want to… | Use |
|---|---|
| run one array operation on one scene | rasterio + numpy directly |
| reuse a remote-sensing step across scenes and scripts | an Operator (define one) |
| chain two to six steps | Sequential (a | b | c) |
| branch, fan in, or return several named outputs | Graph (branching pipelines) |
| run a model tile by tile over a large raster | geoops.patch_ops (tile → operate → stitch) |
| find and load scenes from STAC or local files | geocatalog, then pass the GeoArray in |
What’s inside¶
Every public operator is importable from the top level (gz.NDVI) and
from its family (gz.indices.NDVI). Each family also exports its pure
numpy primitives (gz.indices.ndvi).
| Namespace | What it does | Reference |
|---|---|---|
| core | Operator, Sequential, Graph, Input, Branch, Switch, Fanout, Tap, Snapshot, … (from pipekit) and ModelOp | Core |
geoops.carrier, geoops.testing | helpers that keep the GeoArray contract, and check_operator | Carrier |
radiometry | DN ↔ radiance ↔ reflectance, sun geometry, brightness temperature, DOS1, stretches | Radiometry |
indices | spectral indices: NDVI, EVI, NDWI, NBR, NDSI, … | Indices |
qa | cloud and quality masks from QA bits, SCL classes and sensor presets | QA |
mask | geometry and DEM masks, mask morphology and algebra, ApplyMask | Mask |
spectral | band selection, stacking, band math, spectral resampling | Spectral |
geom (+ geom.coregister) | reproject, resample, crop, tile, rasterise, swath geometry, registration | Geometry |
compositing | temporal composites and multi-source fusion | Compositing |
restore | denoising, despeckling, destriping, gap filling, MNF | Restore |
segment | thresholds, superpixels, watershed and other skimage segmentations | Segment |
measure | connected components, region properties, contours | Measure |
feature | edges, blobs, corners, Hough transforms, local features | Feature |
plume | methane and CO₂ plume retrieval, masks, footprints, mass and flux | Plume |
matched_filter | hyperspectral matched filters and background statistics | Matched filter |
augment | augmentations that respect georeferencing and physical bands | Augment |
normalize | per-band scalers, non-linear scaling, histogram stretch and matching | Normalize · how-to |
learn | scikit-learn estimators as pixel-wise operators | Learn |
einx | einstein-notation tensor operations that keep georeferencing | Einx |
viz | composites, display stretches, colormaps, hillshade, overlays | Viz |
io | window readers, HDF and NetCDF readers, GeoTIFF / COG / Zarr writers | IO · how-to |
patch_ops | geopatcher as operators: GridSampler, ApplyToChips, MergePatches, label-aware samplers | Tile → operate → stitch |
Next steps¶
Concepts: the Operator contract,
SequentialandGraph, control flow, observers, fitted operators, band names, mask polarity.How-to guides: define an operator · branching pipelines · tile → operate → stitch · normalise for training and inference · read HDF and NetCDF.
Tutorial: operators on Sentinel-2 over Lake Tahoe.
Reference: start at Core; the capability index lists every public name once.
Changelog:
packages/geotoolz-ops/CHANGELOG.md.