{
  "type": "analytics",
  "description": "Zonal statistics of fused.catalog imagery over polygons from an upstream node, shown on a map, a table and a chart",
  "hasChildren": false,
  "propsSchema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
      "sql": {
        "description": "DuckDB SQL that returns the polygons, with {{udf_name}} and $param placeholders, e.g. \"SELECT * FROM {{fields}}\". Without sql or url the widget reads the node connected to it by an edge (the most recently connected one when there are several). A GeoParquet or GeoDataFrame geometry column, WKB, WKT or GeoJSON text all work. Polygons are read in EPSG:4326.",
        "type": "string"
      },
      "url": {
        "description": "URL of a GeoJSON FeatureCollection to read the polygons from, when there is no sql.",
        "type": "string"
      },
      "labelColumn": {
        "description": "Column whose value names each polygon in the chart, table and map tooltip. Defaults to a name or id column, else the row number (#1, #2, ...). Downloads always keep every input column and add zone_id, the input row number.",
        "type": "string"
      },
      "collections": {
        "description": "fused.catalog imagery collections to compute statistics over, by id (e.g. [\"hls2-s30\", \"sentinel-1-rtc\"]). Defaults to [\"hls2-s30\"].",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "bands": {
        "description": "Bands per collection, e.g. { \"hls2-s30\": [\"red\", \"nir\"] }. Defaults to the bands of the collection's first visual (true colour for optical imagery).",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "stats": {
        "description": "Statistics per band. Defaults to [\"mean\", \"std\"].",
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "mean",
            "std",
            "min",
            "max"
          ]
        }
      },
      "time": {
        "description": "Date range \"start/end\" for time series collections. Defaults to the last 90 days. Static and yearly products read every date they have.",
        "type": "string"
      },
      "composite": {
        "description": "How scenes are grouped before the statistics: \"none\" (each scene), \"day\", \"weekly\", \"biweekly\", \"month\", \"year\" or \"all\". Defaults to \"weekly\".",
        "type": "string",
        "enum": [
          "none",
          "day",
          "weekly",
          "biweekly",
          "month",
          "year",
          "all"
        ]
      },
      "reducer": {
        "description": "How each period's scenes are combined. Defaults to \"median\".",
        "type": "string",
        "enum": [
          "median",
          "mean",
          "min",
          "max",
          "first",
          "last"
        ]
      },
      "maskClouds": {
        "description": "Leave out cloud and cloud shadow pixels of collections with a cloud mask. Defaults to true.",
        "type": "boolean"
      },
      "maxCloudPct": {
        "description": "Skip a scene whose cloud cover inside a polygon is above this percentage, for collections with a cloud mask. Needs maskClouds. Defaults to 100.",
        "type": "number",
        "minimum": 0,
        "maximum": 100
      },
      "style": {
        "description": "CSS string for the outer element.",
        "type": "string"
      }
    },
    "description": "Analytics over polygons. Zonal statistics: for each polygon of the node connected to it (a GeoJSON file, GeoParquet, a UDF returning a GeoDataFrame or a widget publishing a SQL source; or the sql or url when set), and each picked fused.catalog imagery dataset, the reader computes the mean, standard deviation, min and max of the chosen bands over the polygon's pixels for every date or composite period, with clouds masked. Settings sit in rows that open one at a time: datasets with their bands (true colour bands by default), statistics (mean and standard deviation by default), dates, composite and a cloud cover limit. Values are scaled to the units the catalog lists (reflectance for HLS and Landsat). Results show as a map coloured by the picked statistic and date, a table, and a chart of the median and middle 50% of all polygons over time with up to 5 picked polygons (click them on the map or in the table). Downloads (CSV, or GeoParquet with geometry) keep every input column and add zone_id, the input row number, with a row per polygon and date. Multi-part polygons are skipped; a single-part MultiPolygon is read as its polygon. Up to 4096 polygons go in one request and more are sent in batches.\n\n## Example\n\n```json\n{ \"type\": \"analytics\", \"props\": { \"sql\": \"SELECT * FROM {{fields}}\", \"collections\": [\"hls2-s30\", \"sentinel-1-rtc\"], \"style\": \"height: 640px\" } }\n```"
  }
}
