name: bingham-canyon-mine
version: "0.1"
category: features-objects
themes: [terrain, infrastructure]
family: sar-texture-structural-analysis
status: draft                          # AOI DOES NOT MATCH THE SUBJECT. The referenced
                                       # ICEYE scene footprint sits ~97 km west of the
                                       # Bingham Canyon pit (see inputs.aoi.notes), so the
                                       # narrative below is not supported by the pixels.
                                       # Needs re-siting onto a scene that covers the mine,
                                       # or renaming to its true subject, before it can be
                                       # presented as a mine analysis. As of 2026-08-24 the
                                       # ICEYE open-data catalog (472 STAC items) has no
                                       # scene covering Bingham Canyon; nearest is this one.
description: >
  The Bingham Canyon open-pit copper mine in Utah — 1.2km deep, 4km wide,
  producing ~25% of US copper, and visible from space since before Landsat
  existed. ICEYE X-band Spotlight SAR at sub-meter resolution captures the pit
  wall geometry, tailings pond extent, and the disturbed texture zone left by
  the 2013 Manefay Slide — the largest non-volcanic landslide in North American
  recorded history, which removed ~130 million tonnes of material from the NW wall.

  CAVEAT (2026-08-24): the scene this recipe reads does not actually cover Bingham
  Canyon. Its footprint is roughly 97 km west of the pit, over open desert in Tooele
  County, so the pit walls, tailings ponds and Manefay Slide described above are not
  present in the imagery. The compute graph is a valid SAR texture and edge chain and
  will run, but its outputs describe desert terrain, not the mine.

settings:
  default_bbox: [-113.332, 40.477, -113.263, 40.529]   # Bingham Canyon pit + tailings
  default_crs: EPSG:32612                               # UTM 12N, metric
  backscatter_scale: 32768.0    # ICEYE uint16 midpoint — normalize to linear scale
  edge_detect_sigma: 2.0        # Canny edge detector sigma for pit boundary
  glcm_window: 15               # GLCM texture window size in pixels

inputs:
  aoi:
    bbox: [-113.332, 40.477, -113.263, 40.529]
    crs_target: EPSG:32612
    notes: >
      UNVERIFIED AOI. This bbox is the footprint of ICEYE scene 9RPQMV, whose STAC
      item centroid is 40.503°N, -113.297°W. The Bingham Canyon pit is at
      40.523°N, -112.151°W, about 97 km east of this footprint, so this scene does
      not cover the mine. The scene thumbnail shows basin-and-range desert, unpaved
      roads and fenced enclosures in Tooele County, with no open pit. The earlier
      note here claimed a "pit centroid ~40.52°N, -113.30°W"; that coordinate is not
      the mine. See `status` above before treating any output as a mine analysis.

  date_range:
    start: "2025-11-04"
    end: "2025-11-04"   # Single scene

  scene:
    platform: ICEYE-X46
    acquisition_datetime: "2025-11-04T17:46:58.08Z"
    orbit_state: ascending
    off_nadir_angle_deg: 32.6
    polarization: VV
    instrument_mode: Spotlight
    sar_frequency_band: X        # 9.6 GHz center frequency

layers:

  # ── SOURCE ──────────────────────────────────────────────────────────────────

  source/iceye-grd:
    type: raster
    uri: "https://iceye-open-data-catalog.s3.amazonaws.com/data/spot-fine/ICEYE_9RPQMV_20251104T174653Z_6898547_X46_SLF3L/ICEYE_9RPQMV_20251104T174653Z_6898547_X46_SLF3L_GRD.tif"
    # Direct S3 asset — no STAC query needed. Single scene from ICEYE Open Data Campaign.
    #
    # 2026-08-24: ICEYE reorganized the open-data bucket; the previous uri now 404s:
    #   https://iceye-open-data-catalog.s3-us-west-2.amazonaws.com/sar-data/tasks/open_data/2025_Open_Data_Campaign/6898547/ICEYE_GRD_SLF3L_9RPQMV_20251104T174653Z__6898547.tif
    # The scene itself is still published. The uri above is the `grd-cog` asset href
    # from its STAC item, verified 2026-08-24 (HTTP 200, image/tiff, 709,539,959 bytes,
    # GDAL COG layout IFDS_BEFORE_DATA). Resolve future moves from the STAC item:
    #   https://iceye-open-data-catalog.s3.amazonaws.com/stac-items/2025/11/ICEYE_9RPQMV_20251104T174653Z_6898547_X46_SLF3L.json
    description: >
      ICEYE Spotlight GRD, VV polarization, X-band. 20,000 × 20,000 pixels, uint16.
      Ground Range Detected: phase discarded, intensity preserved.
      Off-nadir 32.6° from ascending orbit — the near wall (west face) will show
      foreshortening; far wall (east face) may show layover at steep sections.
    params:
      bbox: [-113.332, 40.477, -113.263, 40.529]   # COG spatial window — read only the pit
      assets:
        - GRD    # Only asset needed: uint16 SAR intensity, VV polarization

  # ── COMPUTE ─────────────────────────────────────────────────────────────────

  compute/backscatter-db:
    type: raster
    description: >
      Convert ICEYE uint16 GRD to calibrated backscatter in dB.
      Formula: sigma_dB = 10 * log10(GRD_uint16 / 32768.0).
      Typical ranges: open pit walls -15 to -5 dB; tailings pond (smooth) < -20 dB;
      road surfaces and corner reflectors > 0 dB.
    compute:
      op: raster_calc
      inputs:
        data: { layer: source/iceye-grd }
      params:
        expression: "10.0 * log10(GRD / backscatter_scale + 1e-10)"
        backscatter_scale: "${settings.backscatter_scale}"
        output_band: sigma_db

  compute/pit-boundary:
    type: vector
    description: >
      Pit rim boundary extracted by Canny edge detection on the backscatter map.
      The pit wall creates a sharp backscatter contrast with the surrounding terrain.
    compute:
      op: raster_edge_detect
      inputs:
        raster: { layer: compute/backscatter-db }
      params:
        method: canny
        sigma: "${settings.edge_detect_sigma}"
        low_threshold_db: -18.0
        high_threshold_db: -8.0
        vectorize: true
        simplify_tolerance_m: 5.0

  compute/wall-texture:
    type: raster
    description: >
      GLCM contrast texture over the backscatter map. High contrast = rough wall face;
      low contrast = smooth tailings pond or road. The 2013 Manefay Slide zone
      (NW wall) shows distinctive chaotic texture from the disturbed rock mass.
    compute:
      op: raster_glcm
      inputs:
        raster: { layer: compute/backscatter-db }
      params:
        metrics: [contrast, homogeneity, energy]
        window_size: "${settings.glcm_window}"
        output_band: glcm_contrast

  # ── RESULTS ─────────────────────────────────────────────────────────────────

  result/backscatter-map:
    type: raster
    description: Calibrated VV backscatter COG in dB (float32). The primary analysis layer.
    compute:
      op: raster_identity
      inputs:
        data: { layer: compute/backscatter-db }
      params:
        format: cog
        dtype: float32
        overview_levels: [2, 4, 8, 16]

  result/pit-boundary-vector:
    type: vector
    description: >
      Pit rim polygon from edge detection. GeoJSON, EPSG:4326.
      Use with the Sentinel-2 optical context layer to validate geometry.
    compute:
      op: vector_identity
      inputs:
        data: { layer: compute/pit-boundary }

outputs:
  primary:
    - result/backscatter-map       # COG — calibrated dB backscatter
    - result/pit-boundary-vector   # GeoJSON — pit rim polygon
  show_your_work:
    - compute/wall-texture         # COG — GLCM contrast texture

cache:
  scope:
    - inputs.aoi.bbox
    - inputs.scene.acquisition_datetime
    - settings.edge_detect_sigma
    - settings.glcm_window
  storage: ./cache/
  reuse_policy: hash_inputs

license:
  recipe: Apache-2.0
  output_dataset: CC-BY-4.0
  upstream_data:
    - source: iceye-open-data
      license: ICEYE Open Data License
      note: Free for non-commercial research. Commercial use requires ICEYE agreement.
      url: https://iceye-open-data-catalog.s3-us-west-2.amazonaws.com/
