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
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | count | |
| limit | No | Max rows to return (default 100; server-side cap applies). | |
| geometry | No | '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 |
| relation | No | intersects | |
| min_count | No | Keep only left features with at least this many matches. | |
| distance_m | No | Required for relation='dwithin' (metres). | |
| left_layer | Yes | ||
| order_desc | No | ||
| right_layer | Yes | ||
| left_filters | No | Attribute filters on the layer, combined with AND. | |
| right_column | No | Numeric right column for mode sum/avg. | |
| right_columns | No | Right columns to attach (mode 'attach'). | |
| right_filters | No | Filters on the right layer. |