# catalog/operations/raster/reproject.yaml

id: raster_reproject
name: Reproject
description: >
  Reproject raster to a new coordinate reference system (CRS). Supports
  standard EPSG codes and proj4 strings. Uses specified resampling method
  for pixel interpolation.
version: 1.0.0
category: raster
type: raster-to-raster
default_implementation: native

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

requires: {}  # structural — operates on any raster

outputs:
  - name: reprojected
    type: raster
    format: cog
    description: Reprojected raster in target CRS

params:
  crs:
    type: string
    required: true
    description: Target CRS (e.g., "EPSG:4326", "EPSG:32612")
  resolution:
    type: number
    description: Target resolution in CRS units (optional, uses source if not specified)
    min: 0.0001
    max: 100000
  resampling:
    type: enum
    default: bilinear
    enum: [nearest, bilinear, cubic, lanczos]
    description: >
      Resampling method:
      - nearest: fast, preserves categorical values
      - bilinear: good for continuous data
      - cubic: smoother, may overshoot
      - lanczos: high-quality, slower

granularity:
  min_resolution_m: 0.1
  max_resolution_m: 100000
  output_resolution: fixed
  requires_continuous: false
  suitable_aoi_km2:
    min: 0.001
    max: 1000000
  realtime_max_km2: 1000

uncertainty:
  error_model: additive
  factors:
    - name: resampling_method
      description: "Interpolation introduces smoothing (bilinear) or artifacts (nearest)"
      severity: medium
      mitigations:
        - "Bilinear for continuous data, nearest for categorical"
        - "Minimize reprojection steps"
    - name: datum_shift
      description: "Datum transformation has inherent positional uncertainty"
      severity: low
  limitations:
    - "Repeated reprojection accumulates error"

execution:
  realtime_max_km2: 1000
  cost_per_km2: 0.0005
  time_per_km2_sec: 0.15
  memory_profile: medium
  profile:
    cpu: medium
    memory: medium
    io: high
  scaling:
    model: linear
    parallelizable: true
    min_chunk_km2: 1

cache_policy:
  ttl_days: 365
  invalidate_on: [source_update, param_change]

# 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:
  rust-wasm:
    handle_function: h_raster_reproject
  js:
    function: raster_reproject
  python:
    function: geo.raster.reproject
    dispatch: folia/compute.py _BUILTIN_OP_MAP

display_hints:
  map:
    renderer: maplibre

ui:
  icon: globe
  color: "#2E8B57"
