Skip to main content
Glama

zonal_statistics

Idempotent

Compute raster statistics within vector zones using exact fractional pixel coverage, with automatic CRS alignment and optional weighted statistics.

Instructions

Statistics of a raster within each vector zone (exact fractional pixel coverage).

stats: subset of count/sum/mean/median/min/max/stdev/variance/majority/minority/ variety (default: count, mean, min, max). Zones are aligned to the raster CRS automatically; the decision is recorded in the provenance manifest. weights_path: a single-band raster of weights on the SAME grid as the values (same CRS, cells and registration; otherwise refused with how to align it), for weighted_mean/weighted_sum/weighted_stdev/weighted_variance/weighted_frac -- e.g. mean heat per zone weighted by population (default stats then: count, mean, weighted_mean). A cell with a value and no weight counts with weight 0, and the record names the zones where that happened. Zones without a CRS are refused; warnings and repairs keys in the result flag a suspicious outcome or geometry MapSmith had to repair. Requires the [raster] extra.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statsNo
zones_pathYes
output_pathYes
raster_pathYes
weights_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.6.1
    • addedInput schema / properties / weights_path
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Weights Path"
      +}
  2. First observedv0.3.0

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already mark the tool as idempotent and non-destructive. The description adds valuable behavioral details beyond that: automatic CRS alignment recorded in provenance, weight handling (cells with no weight count as 0, zones named in records), and the warnings/repairs result keys for geometry issues. This enriches the agent's understanding of side effects and edge cases without contradicting the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is fairly long but well-structured into a lead sentence and focused paragraphs for stats, weights, and error handling. Every sentence adds meaningful information—no filler. It front-loads the core purpose and then dives into specifics, which is effective for an agent scanning for key details. A slight trim could improve it, but it's well-organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 5 parameters, 0% schema coverage, and an output schema exists (so return values are covered elsewhere), the description is quite complete. It covers CRS alignment, weight edge cases, result keys, and the required extra. It does not explicitly state that output_path is written, but that's implied by the parameter name and the tool's function. Overall, an agent has enough context to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the full burden. It explains the stats parameter's options and defaults, and elaborates on weights_path semantics (same grid requirement, weighting modes, behavior with missing weights). The other parameters (raster_path, zones_path, output_path) are self-explanatory from their names, and the description adds context for zones (CRS alignment) and output (warnings/repairs keys). This compensates well for the undocumented schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise verb+resource statement: 'Statistics of a raster within each vector zone (exact fractional pixel coverage).' It then enumerates the stats options and weighted-statistics mode, which unambiguously distinguishes it from the sibling raster tools (hillshade, slope, etc.) without needing to name them. An agent immediately knows what this tool does and how it differs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides strong constraints and prerequisites (CRS alignment, refusal of zones without CRS, required [raster] extra) but does not explicitly state when to choose this tool over alternatives. It implies the use case (zonal analysis) but never contrasts it with e.g. spatial_join or overlay_layers. That leaves some inference to the agent, so a 3 is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.