stac_zonal_stats
Read raster values within zones (points or polygons) to compute per-zone statistics like mean, median, min, max, and detect local anomalies using a z-score comparison with surrounding background.
Instructions
Read out a raster's values within zones — the inference step after a fetch.
Given a stored raster artifact (e.g. an NDVI index from stac_compute_index, or any GeoTIFF from stac_download_bands) and target zones, return per-zone statistics (n_valid, mean, std, min, max, median, p10, p90).
Zones are either circular buffers around points, or GeoJSON polygons:
points: [[x, y], ...] centres in
zones_crs, each summarised withinbuffer_m.geojson: a geometry / Feature / FeatureCollection (polygons) in
zones_crs.
Pass background_m (> buffer_m) to also get a LOCAL ANOMALY readout: each
point's mean is compared to the surrounding annulus (buffer_m..background_m)
and reported as a z-score, with anomalous set when |z| >= z_threshold. This
is the direct "is the signal at this location anomalous vs its surroundings?"
answer — e.g. a cropmark/soil-mark over a buried feature in an NDVI raster.
Args: artifact_id: A GeoTIFF raster artifact (NOT a PNG preview). points: Zone centres [[x, y], ...] in zones_crs (e.g. BNG eastings/northings). buffer_m: Circular zone radius in metres (raster must be projected). background_m: Outer annulus radius in metres → enables the z-score readout. geojson: Alternative polygon zones (geometry/Feature/FeatureCollection). zones_crs: CRS of points/geojson, e.g. "EPSG:27700" (BNG) or "EPSG:4326". labels: Optional labels for points (e.g. HER refs). band: 1-based band index to read. z_threshold: |z| at/above which a point is flagged anomalous (default 2.0). output_mode: "json" or "text".
Returns: Per-zone statistics, plus a local z-score when background_m is given.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| band | No | ||
| labels | No | ||
| points | No | ||
| geojson | No | ||
| buffer_m | No | ||
| zones_crs | No | EPSG:4326 | |
| artifact_id | Yes | ||
| output_mode | No | json | |
| z_threshold | No | ||
| background_m | No |