Nearest neighbor
Add nearest_distance_m — geographic meters to the closest other feature in the same layer.
intermediateA nearest neighbor step adds a numeric attribute nearest_distance_m: the geographic distance in meters from each feature to the closest other feature in the same pipeline input (self-join on geography). Geometry is unchanged.
There is no second layer and no K (k-nearest list). For distance to another layer, use Spatial join with predicate nearest.
Inputs
- Source layer. Any geometry type. Null geometries are skipped.
- No parameters in the derived-layer builder.
Output
Source attributes plus nearest_distance_m (nullable number). A single-row input yields NULL for that field (nothing else to measure against). If the source already had a field named nearest_distance_m, this step overwrites it.
How to use it on its own
- New-item wizard → Derived layer.
- Pick a Source.
- Add a Nearest neighbor step.
- Save.
From a data layer Analyze tab
On a data layer's Analyze tab, Nearest neighbor for this layer opens a short title form and creates a private derived layer with a single nearest-neighbor step against that layer (same PostGIS path as above). The guide states O(N²) cost and that a single-row layer yields NULL. Expect a short server job, not an instant browser result.
Examples
- Isolation score. Source: wells. Output adds meters to the nearest other well. Follow with Top N on
nearest_distance_mascending to list the most clustered, or descending for the most isolated. - QA for duplicates. Very small
nearest_distance_mvalues may flag near-duplicate points.
Notes
- O(N²) per read. The join runs over the full input. For more than a few thousand features, expect slower materialization. Recipe
featureLimitcaps output rows but does not shrink the join input. A GIST / KNN path is not provisioned in v1. - Meters on the spheroid via
ST_Distanceon geography — not planar degrees. - Same layer only. Other-layer proximity is spatial join nearest, not this tool.