nearest
Finds the k closest features in a layer to a coordinate point or another layer's features, returning distances in metres and supporting an optional maximum distance.
Instructions
The k nearest features of layer to a reference (lon/lat point or feature(s) of another layer), with distance_m in metres. Optional max_distance_m. If the user did not say what 'nearest' is relative to, ASK.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | Number of neighbours (1-100). | |
| lat | No | Latitude (WGS84, north-south, -90..90). | |
| lon | No | Longitude (WGS84, east-west, -180..180). | |
| layer | Yes | ||
| columns | No | Attribute columns to return (default: all non-geometry). | |
| filters | No | Attribute filters on the layer, combined with AND. | |
| 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 |
| max_distance_m | No | Ignore features farther than this (metres). | |
| reference_layer | No | Measure from the geometry of feature(s) in this layer instead of a lon/lat point. | |
| use_all_matches | No | ||
| reference_filters | No | Filters that pick the reference feature(s) in reference_layer (e.g. name = 'X'). |