# catalog/operations/analysis/histogram.yaml

id: analysis_histogram
name: Histogram
description: >
  Compute histogram of raster values. Returns counts and bin edges
  for analyzing value distribution.
version: 1.0.0
category: analysis
type: raster-to-stats
default_implementation: native

inputs:
  - name: raster
    type: raster
    format: geotiff
    description: Input raster to analyze
    required: true

# Structural: histogram of any raster's pixel values. requires: omitted.

outputs:
  - name: histogram
    type: stats
    format: json
    description: Histogram data with counts and bin edges

params:
  bins:
    type: integer
    default: 256
    description: Number of histogram bins
    min: 2
    max: 10000

cache_policy:
  ttl_days: 30
  invalidate_on: [source_update]

# backends: audited 2026-08-14 (defect 50). A key means a runtime that DISPATCHES this op —
# folia-engine `dispatch_op` (products/sdk/folia-engine/src/lib.rs), a `registerOp`/OP_TABLE
# entry in packages/compute, `_BUILTIN_OP_MAP` in folia/compute.py, or a backend manifest
# (folia/backends/*/backend.yaml).
backends:
  python:
    function: geo.stats.histogram
    dispatch: folia/compute.py _BUILTIN_OP_MAP

display_hints:
  chart:
    renderer: observable-plot
    chartType: bar
  table:
    renderer: tanstack-table

ui:
  icon: bar-chart-2
  color: "#4169E1"
