Regression Methods for Geospatial DataPart 1 of 4Introductory · Updated December 1, 2026

Nearest-Neighbour Regression

Measurements of a field are often available only at scattered points, and the value is needed somewhere else. Nearest-neighbour regression estimates it by averaging the observations near the query point. Every method later in this series refines this estimator rather than replacing it.

The estimate is the mean of the nearby observations

Given observations D={(xi,yi)}i=1N\mathcal{D} = \{(\mathbf{x}_i, y_i)\}_{i=1}^N and a query point xq\mathbf{x}_q, define a neighbourhood N(q)\mathcal{N}(q) and average over it:

y^(xq)=1∣N(q)∣∑i∈N(q)yi\hat{y}(\mathbf{x}_q) = \frac{1}{|\mathcal{N}(q)|} \sum_{i \in \mathcal{N}(q)} y_i

The estimator assumes no functional form for the field (it is non-parametric). Its only assumption is that the field varies slowly enough for points near xq\mathbf{x}_q to carry information about the value at xq\mathbf{x}_q. Everything therefore depends on how “near” is defined.

Per-axis length scales define the distance

In a geospatial problem the axes are not commensurable. An observation made along a flight track has a latitude, a longitude, a time and a flight level:

xi=(ϕi,λi,ti,fi)\mathbf{x}_i = (\phi_i, \lambda_i, t_i, f_i)

Measuring the distance between two such points requires stating how many minutes, and how many feet of altitude, are equivalent to a kilometre. The units do not answer this; the choice is a model of the field’s correlation structure. The standard approach gives each axis its own length scale and divides by it before taking the norm:

r(xq,xi)=(dgeols)2+(∣tq−ti∣lt)2+(∣fq−fi∣lf)2r(\mathbf{x}_q, \mathbf{x}_i) = \sqrt{\left(\frac{d_{\text{geo}}}{l_s}\right)^2 + \left(\frac{|t_q - t_i|}{l_t}\right)^2 + \left(\frac{|f_q - f_i|}{l_f}\right)^2}

where dgeod_{\text{geo}} is the great-circle distance. Each term is dimensionless: a separation in units of the distance along that axis over which the field changes appreciably. The neighbourhood is everything within a cutoff RR:

N(q)={ i:r(xq,xi)≤R }\mathcal{N}(q) = \{\, i : r(\mathbf{x}_q, \mathbf{x}_i) \le R \,\}

Giving each input dimension its own scale is known in machine learning as automatic relevance determination. If a fitted length scale grows without bound, every point is close along that axis, so the axis no longer affects which points are neighbours; a length scale that runs to the top of its search range suggests that the axis carries little signal.

Wide, thin layers give a disc-shaped neighbourhood

With ls=lt=lfl_s = l_t = l_f the neighbourhood is a sphere. Ice-supersaturated regions, where persistent contrails form, are layered: tens to hundreds of kilometres wide but only a few hundred feet deep. The neighbourhood that matches them is a flat disc (Figure 1).

Different altitude:barely countsSimilar altitude:counts for most±10 FL≈ 1,000 ft±50 km✈Formed here, but nevervisible from orbitIllustrative length scales: l_s ≈ 50 km, l_t ≈ 1 h, l_f ≈ 10 FL — far wider than it is deep.
Figure 1.The neighbourhood defined by the length scales. Observations inside it are averaged; observations at a similar horizontal distance but a different altitude fall outside it. The values are illustrative: a vertical scale of 10 flight levels (about 1,000 ft) against a horizontal scale of 50 km, a ratio of more than a hundred to one.

A flight level is 100 ft, so lf=10l_f = 10 FL is 1,000 ft, or 0.305 km. With ls=50l_s = 50 km,

lslf=50 km0.305 km≈160\frac{l_s}{l_f} = \frac{50\ \text{km}}{0.305\ \text{km}} \approx 160

With these scales and a cutoff R=5R = 5, an aircraft 100 km away at the same altitude and time is a neighbour (r=2r = 2), while one directly overhead and 10,000 ft higher is not (r=10r = 10), the opposite of what geographic distance alone would give.

Inside the ball 72 / 90Effective sample size 29.8Aspect ratio 164:1
Figure 2.The same observations seen from above and from the side, with the query point marked by a cross. Dot size is the kernel weight introduced in the next tutorial; here only membership of the dashed boundary matters. Changing the preset changes the length scales: the tight preset shrinks the neighbourhood in every direction, and the tall preset makes it as deep as it is wide. The dashed boundary is the slice at zero time separation, so a dot inside it can still be excluded by its age.

A fixed radius or a fixed number of neighbours

The neighbourhood N(q)\mathcal{N}(q) can be defined in two ways, which fail differently.

  • Fixed kk: take the kk closest points at any distance. The neighbourhood is never empty, but in a sparse region the kk closest observations may be hundreds of kilometres away, and the estimate is then built from points that carry little information about the query.
  • Fixed radius RR: take every point within the cutoff. In a sparse region the neighbourhood is empty, a condition that can be detected and handled explicitly, although the estimator then needs a fallback value, which the next tutorial provides.

Scanning all NN observations for every query costs O(N)O(N) per query. A ball tree reduces this: it recursively partitions the points into nested hyperspheres, and at query time discards any ball whose closest possible point is beyond the cutoff. For geospatial data the tree is usually built on latitude and longitude in radians under the haversine metric and used as a geographic pre-filter; the time and flight-level conditions are then applied to the much smaller set of candidates. The pre-filter must return a superset of the true neighbourhood, or the tree drops points the metric would have kept.

Assumptions and failure modes

RR controls smoothing, with the usual bias–variance trade-off. A small RR gives few neighbours and an estimate that follows local structure but varies with the noise in a handful of points. A large RR gives a stable estimate that averages away the structure of interest.

Within N(q)\mathcal{N}(q) every observation has the same weight: a measurement 1 km away and one at R⋅lsR \cdot l_s contribute equally, and one just beyond the cutoff contributes nothing. The estimate is therefore a step function of the data; small changes in RR or in the query position move neighbours in or out and make y^\hat{y} jump. Physical fields do not change discontinuously at the cutoff distance, so the influence of an observation should decrease smoothly with distance.

Summary

  • Nearest-neighbour regression averages the observations within a neighbourhood of the query.
  • On mixed axes the distance metric, set by one length scale per axis, is the main modelling choice; for atmospheric layers the neighbourhood is much wider than it is deep.
  • A fixed radius makes sparse regions detectable as empty neighbourhoods; a fixed kk hides them.
  • Equal weights inside a hard boundary make the estimate discontinuous.

Kernel Regression replaces the hard boundary with a smooth weight; nearest-neighbour regression is its special case with a rectangular kernel.

References

  • Cover, T. M., & Hart, P. E. (1967). Nearest neighbor pattern classification. IEEE Transactions on Information Theory, 13(1), 21–27. doi:10.1109/TIT.1967.1053964
  • Stone, C. J. (1977). Consistent nonparametric regression. The Annals of Statistics, 5(4), 595–620. doi:10.1214/aos/1176343886
  • Uhlmann, J. K. (1991). Satisfying general proximity/similarity queries with metric trees. Information Processing Letters, 40(4), 175–179. doi:10.1016/0020-0190(91)90074-R
  • Rasmussen, C. E., & Williams, C. K. I. (2006). Gaussian Processes for Machine Learning. MIT Press. doi:10.7551/mitpress/3206.001.0001 (Chapter 5 covers automatic relevance determination.)