Skip to main content
Glama

spatial_join

Joins two spatial layers per left feature to count, sum, average, or attach matching right features for map-ready analysis.

Instructions

Spatial join between two layers, per feature of the LEFT layer. mode='count' (default) counts related RIGHT features (e.g. pharmacies per district: left=districts, right=pois, relation='contains'); 'sum'/'avg' aggregate a numeric right_column; 'attach' lists matched pairs with right_columns. relation: intersects | within | contains | dwithin (needs distance_m). Returns the LEFT geometry so it can be mapped (choropleth-like).

Input Schema

NameRequiredDescriptionDefault
modeNocount
limitNoMax rows to return (default 100; server-side cap applies).
geometryNo'auto' (default): full geometry if small, else representative points; 'full'; 'centroid'; 'none' (attributes only). The complete geometry is always kept server-side under result_id for render_map.auto
relationNointersects
min_countNoKeep only left features with at least this many matches.
distance_mNoRequired for relation='dwithin' (metres).
left_layerYes
order_descNo
right_layerYes
left_filtersNoAttribute filters on the layer, combined with AND.
right_columnNoNumeric right column for mode sum/avg.
right_columnsNoRight columns to attach (mode 'attach').
right_filtersNoFilters on the right layer.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral burden; it explains mode behavior, relation semantics, the distance_m dependency for dwithin, and that LEFT geometry is returned. It does not explicitly state that the operation is read-only, describe side effects, or mention pagination/performance characteristics.

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 dense but front-loaded: purpose first, then modes, then relation options and return behavior. It uses semicolons effectively and wastes little text for a 13-parameter tool, though it could be slightly more scannable.

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

Completeness3/5

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

For a 13-parameter tool with no output schema and no annotations, the description explains the core join semantics but does not fully cover output shape, result_id handling, filtering behavior, or how limit/order_desc affect results. It is adequate for the main workflow but leaves nontrivial gaps.

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 coverage is 62%, and the description adds important meaning for the key ambiguous parameters: mode behaviors with examples, relation options, and the dwithin/distance_m dependency. It also clarifies right_column versus right_columns usage, though some parameters such as order_desc remain undocumented beyond the schema.

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

Purpose4/5

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

States a specific verb ('spatial join') and resource ('two layers, per feature of the LEFT layer'), and explains what the operation computes. It makes the two-layer, per-left-feature scope clear, though it does not explicitly name sibling alternatives.

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?

Provides a concrete usage example (pharmacies per district) and maps each mode to a scenario, which gives useful implied guidance. However, it never says when to prefer spatial_join over aggregate, spatial_filter, within_distance, or nearest, and gives no exclusions.

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